Running ASP.Net MVC on IIS 5.1
When i start to create my first ASP.Net MVC application and try run it on IIS 5.1 ( Win XP) i faced problems as it could not run as its run on the project run mode. There was 2 particular problem , first the home page does not apply the CSS or formating and second problem u cannot navigate to other pages because the controller throw “Page cannot be found” error.
First problem CSS and formating not applied.
Second problem controller throw “Page cannot be found” error
I tried few solutions that i found after googling before but non of them work and leave this problem for while. This including doing some configuration changes in IIS to add .MVC handler but that’s not worked either. Today i googled again to find solution for this and found a solution given by Ajit Shekhawat. You can access the solution page at CodeProject.
There is 2 things suggested by Ajit Shekhawat to solve this problem , i tried and its worked for me
. First step is to modify Page_Load() function on Default.aspx.cs file according the code below .
public void Page_Load(object sender, System.EventArgs e)
{
if (Request.ApplicationPath == “”)
{
HttpContext.Current.RewritePath(Request.ApplicationPath + “home.aspx”);
}
else if (Request.ApplicationPath == HostingEnvironment.ApplicationVirtualPath)
{
HttpContext.Current.RewritePath(Request.ApplicationPath + “/home.aspx”);
}
else
{
HttpContext.Current.RewritePath(Request.ApplicationPath);
}
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(HttpContext.Current);
}
Second step is to modify RegisterRoutes function on Global.aspx.cs as below , (added “.aspx” as extension to controller)
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute(“{resource}.axd/{*pathInfo}”);
routes.MapRoute(“Default”, “{controller}.aspx/{action}/{id}”,
new { controller = “Home”, action = “Index”, id = “” });
}
These modification must be done on project file and publish your project on IIS 5.1 and its should work as its works for me
. The only drawback of these changes is your home controller would have .aspx extension on it and looks weird, see url below.
http://localhost/mvc/Home.aspx/About
Credit for this solution must go to Ajit Shekhawat and original solution can be found at CodeProject
Update
Official solution from Microsoft can be found at ASP.Net page.



I am an organism that turns coffee into software 

3 responses to "Running ASP.Net MVC on IIS 5.1"
You moron !!! it doesn’t work
¯\(º_o)/¯ its work on my machine!
Thanks buddyyyyyyyyyyyyyyyy!
i hv got the solution from ur kind suggestion…
Its really very helpful..
Thanks a lot!
Leave a comment