ASP.NET MVC routing for IIS 6, why ending extension is bad?
Deploying an ASP.NET MVC application to production (on IIS 6) makes the nice looking URL to not work as expected.
Without going into too much details, the issue is ASP.NET needs the .aspx to be present into the URL, in order to be triggered.
So, an URL like
http://www.mycompany.com/Romania/English/Services will lead to a 404 error. Recommended solutions are to adapt the route to http://www.mycompany.com/Romania.aspx/English/Services or to http://www.mycompany.com/Romania.mvc/English/Services, which are not so pretty (second one requires also the mapping of .mvc extension in IIS).
Why not having URLs like:
http://www.mycompany.com/Romania/English/Services.aspx ??
I tested and there is no hidden catch (yes, I thought it might be a technical reason why is not recommended!), but is working as expected.
If you rewrite an application with Web Forms to ASP.NET MVC, step by step, that’s a normal way to do it.
1: routes.MapRoute(
2: "My Company Homepage",
3: "{country}/{language}/Products.aspx",
4: new
5: {
6: controller = "Product",
7: action = "List",
8: country = "Romania",
9: language = "English"
10: });
Funny, even the permalink of this post has the filename before parameters, just to trigger the PHP (that blog is hosting on an IIS web server). But still, why not putting the .php extension at the end?
UPDATE: I fixed meanwhile the URL Rewriting of this blog with an .htaccess file