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) { } }
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.
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.
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
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?
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:
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.
I don't have a solution, but I think I found the source to the problem:
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.
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
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
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
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?
You can extend ImageProcessor with your own effects. But you should talk to James South about that
Dave
I just contacted James on twitter about this. Adding ipignore=true to your querystring will make Imageprocessor ignore the request.
Dave
is working on a reply...