Share on FacebookI wanted to try out ASP.NET MVC in order to decide whether or not I could use it for a small project I’m starting, I’ve read nothing than good things about the Framework, but I hadn’t had the chance to try it on a real web site.
The first step though, is making it work. My hosting provider runs the windows server on IIS6, and does not allow custom configuration unless you buy a dedicated server, which I didn’t want to do, for now at least.
There are quite a few blog posts that explain how to run ASP.NET MVC on IIS6, but in all I read you need to have access to the web server configuration, to do one of two things:
This options were no good for me.
The solution was quite simple (well, it became simple after a little bit of research): Add a custom route, and map .aspx files to a controller.
You need to add this to the Global.asax file:
routes.MapRoute("Main", "{controller}/{action}.aspx",
new { controller = "Home", action = "Index" });
routes.MapRoute("Default", "",
new { controller = "Home", action = "Index" });
The only drawback is that you don’t get the “pretty” url you can get if you use IIS7 or have access to IIS6 configuration, but it works.
(Instead of having a url like this: http://yourserver/Home/Index, you get http://yourserver/Home/Index.aspx)
If the framework (MVC) is not installed on the server, you also need to copy the dlls to the bin directory, which they don’t get copied by default, you need to check the “Copy Local” property in the project references.