0
votes

I need a feedback on a routing-related issue I've found while publishing an ASP.NET MVC 2 application. In the global.asax file I defined the following routes:

// Thumbnails routing.
// Sample URL: resizer/resizeImage/200/200/Error/error.jpg
routes.MapRoute("Resizer","Resizer/{action}/{width}/{height}/{folder}/{file}",
new  { controller = "Resizer", action = "ResizeImage", width = 100,height = 100,
folder = "Error", file = "error.jpg"
}   
);
// Default routing.
// Sample URL: /Home/Index
routes.MapRoute("Default",  "{controller}/{action}.aspx/{id}",
new { controller = "Home", action = "Index", id = (string)null }
);  

So, firstly I had to add .aspx for the default routing otherwise the hosting server (Aruba) does not perform properly routing... so first question: is there any other workaround to maintain normal routing (i.e. without adding .aspx)?

The 'Resizer' route should allow to call a controller that should generate thumbnails images: It works locally but not when the web site is published.

It seems that the route like 'resizer/resizeImage/200/200/Error/error.jpg' is not recognized.

How can I handle this issue?

2

2 Answers

0
votes

thanks for your reply.

I modified the routing adding '.aspx' to {action} also in the Resizer route. Now it looks like:

routes.MapRoute("Resizer", 
"Resizer/{action}.aspx/{width}/{height}/{folder}/{file}", 
new { controller = "Resizer", action = "ResizeImage", 
width = 100, height = 100, folder = "Error", file = "error" });

It seems to work properly, it is actually the only way to activate IIS routing.

I also deleted the file extension (.jpg), just to avoid problem with the Dot character.

Marco

0
votes

I don't think there is another way to avoid the .aspx instead the "normal" routing. Any how I don't think it's a big deal. I also think that in the code that you posted (I didn't try it) the routing is not correct: to add the aspx you should put the aspx after the controller name, in the default like in the resizer one. Something like that:

routes.MapRoute("Resizer", 
      "Resizer.aspx/{action}/{width}/{height}/{folder}/{file}", 
      new { controller = "Resizer", action = "ResizeImage", 
      width = 100, height = 100, folder = "Error", file = "error.jpg" });

/Stefano