Click here to Skip to main content
13,202,960 members (56,823 online)
Click here to Skip to main content
Add your own
alternative version


15 bookmarked
Posted 14 Jan 2009

Running a ASP.NET MVC Beta site on IIS 5.1 and 6

, 14 Jan 2009
Rate this:
Please Sign up or sign in to vote.
Running a ASP.NET MVC Beta site on IIS 5.1 and 6

Running a ASP.NET MVC Beta site on IIS 5.1 and 6


During the development of site on ASP.NET MVC I have faced some issues, which is related to IIS (6 and 5.1). I have Windows XP on my development box and Windows 2003 on my production server. I want to use my local IIS during the development and also want to deploy my site on remote server without any modification in codes.


If we create a new project in VS 2008 with ASP.NET MVC Beta and host this template site on IIS (6 or 5.1) then after opening site in browser will get following output.

Issue 1: Design is not applied on root (home) page

Home page does not use css and other formatting, Images. Home page will become:


Issue 2: Call to controller fails and "The page cannot be found" error thrown by IIS.

And if we click on any link, which is actually a call of controller the “The page cannot be found” error thrown by IIS.


Here is the solution for this issue ( One method is suggested to append “.aspx” in controller. Also other methods are provided there but I am not interested in them. Adding “.aspx” in controller will resolve the problem but it will not handle root url issue (Issue 1).


Resolution 1:

Open Default.aspx.cs of root folder in your project. Modify the Page_Load function as per given below. Added codes are formatted Bold.

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");
  IHttpHandler httpHandler = new MvcHttpHandler();

Now application must be working fine on IIS 5.1 and IIS 6 without facing issue 1.

Resolution 2:

To resolve issue# 2, we need to open Global.aspx.cs file and modify RegisterRoutes function. Added codes are formatted Bold.

public static void RegisterRoutes(RouteCollection routes)
   routes.MapRoute("Default", "{controller}.aspx/{action}/{id}", 
   new { controller = "Home", action = "Index", id = "" });

Now application must be working fine on IIS 5.1 and IIS 6 without facing issue 2. But addition of ".aspx" in controller will be displayed in url.

Thanks and Regards,


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Ajit Shekhawat
Architect HCL Technologies
India India
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralLaziness Pin
Shog929-Jan-09 7:49
sitebuilderShog929-Jan-09 7:49 
While i applaud your desire to share solutions to some problems you've encountered, i must disagree with the way in which you've done so. You fail to describe the problems in detail, and provide even less information regarding the mechanism by which your solutions/work-arounds accomplish their goals.

Given that ASP.NET MVC is still in beta, the way such problems manifest themselves is likely to change over time, as are the work-arounds for them. Without sufficient information, this article has little chance of being useful now and even less chance of remaining useful in the near future.

The sad part of this is you likely knew it when you wrote it. The article you link to provides better descriptions of both the problem and solutions, meaning you've essentially make a bad resource out of a good one in writing this article.

Before posting another, i suggest you look at your source material and ask yourself: if someone came to me for help, would i send him a link to my article, or the articles i based it on? If the latter, don't bother submitting your article at all.

GeneralMy vote of 1 Pin
codeguruj23-Jan-09 6:20
membercodeguruj23-Jan-09 6:20 
Generalthere is another simple way in iis6.0 Pin
Haozes14-Jan-09 18:36
memberHaozes14-Jan-09 18:36 
GeneralRe: there is another simple way in iis6.0 Pin
Ajit Shekhawat14-Jan-09 18:42
memberAjit Shekhawat14-Jan-09 18:42 
GeneralRe: there is another simple way in iis6.0 Pin
Haozes14-Jan-09 19:13
memberHaozes14-Jan-09 19:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171020.1 | Last Updated 14 Jan 2009
Article Copyright 2009 by Ajit Shekhawat
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid