Marco Marco - 1 year ago 113
ASP.NET (C#) Question

ASP.Net MVC 2 Routing

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
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?

Answer Source

thanks for your reply.

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

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.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download