Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Calle Bjernekull 28 posts 103 karma points
    May 27, 2015 @ 09:31
    Calle Bjernekull
    0

    Passing url-parameters in custom route

    I'm trying to register a custom route for some API-requests. I want my controller to take care of everything with a specific url-prefix and implemented like this:

    public class StartupHandler : IApplicationEventHandler
    {
    public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
    RouteTable.Routes.MapRoute(
    name: "MyRoute",
    url: "/myroute/{*Data}",
    defaults: new { controller = "MyController", action = "Index"}
    );
    }

    public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
    }
    public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
    }
    }

    This works fine as long as I don't pass any parameters in my url, like http://mydomain/myroute/foo/bar

    But, I want to be able to pass some (optional) parameters to the controller so the url looks like http://mydomain/myroute/foo/bar?a=qwerty. This will give my a 404, and not even an "Umbraco-404". I'll get the regular 404 from IIS.

    The maproute works fine if it's used in another environment without Umbraco installed.

  • Calle Bjernekull 28 posts 103 karma points
    May 29, 2015 @ 08:44
    Calle Bjernekull
    0

    I don't have a solution, but I think I found the source to the problem:

    <add name="ImageProcessorModule" type="ImageProcessor.Web.HttpModules.ImageProcessingModule, ImageProcessor.Web"/>

    If I remove the IMageProcessorModule in web.config everything works. My url is actually a png-file, so that's probably why. But where is this module actually used? Everything seems to work fine without it.

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    May 29, 2015 @ 10:07
    Dave Woestenborghs
    0

    Hi Calle,

    ImageProcessor is used to scale/crop images. THe rich text editor uses it to scale the images to the selected size.

    I wouldn't recommend on disabling it.

    Maybe you can post some more details on what you are trying to achieve. That will give some more insight.

    You can always contact the developer of image processor, James South, on twitter (@James_M_South). He is always very helpful.

    Dave

  • Calle Bjernekull 28 posts 103 karma points
    May 29, 2015 @ 10:55
    Calle Bjernekull
    0

    Hi, thanks for your answer

    I'm trying to build my own image-handler that will add some overlays on the image and return a rendered png (it's project specific and I'm not allowed to give you all the details, maybe after release) . I want all image-url's with a specific prefix ("myroute") should be handled by my control, for example /myroute/some/path/myimage.png. This works fine! But I also want to be able to add some optional parameters like /myroute/some/path/myimage.png?effect=myeffect. But it seems like ImageProcessor is ending the response if there are any parameters.

    The reason that I can't use the "effect"-parameter as a url-segment, is that the path to the image may vary, and "effect" is optional. Any suggestions for workarounds are welcome.

    Edit -> Additional info: This worked very well in another project based on Umbraco 7.0.3

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    May 29, 2015 @ 10:59
    Dave Woestenborghs
    0

    Hi Calle,

    Thanks for the update.

    I don't know what effects you are trying to do but maybe you can achieve some of the effects you are doing using ImageProcessor.

    A lot of effects are possible : http://imageprocessor.org/imageprocessor-web/imageprocessingmodule/

    Dave

     

  • Calle Bjernekull 28 posts 103 karma points
    May 29, 2015 @ 11:33
    Calle Bjernekull
    0

    Effects is just one of the optional parameters and might work. I really tried to stick to ImageProcessingModule, but sadly it's not enought. I really need to render the bitmap by myself. Maybe there's some interface to implement here?

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    May 29, 2015 @ 12:41
    Dave Woestenborghs
    0

    You can extend ImageProcessor with your own effects. But you should talk to James South about that

    Dave

  • Dave Woestenborghs 3504 posts 12133 karma points MVP 8x admin c-trib
    May 29, 2015 @ 13:53
    Dave Woestenborghs
    0

    I just contacted James on twitter about this. Adding ipignore=true to your querystring will make Imageprocessor ignore the request.

    Dave

Please Sign in or register to post replies

Write your reply to:

Draft