0

I'm trying to use ASP.NET MVC with older versions of IIS that have trouble with MVC's default routing. I found a suggestion to add .mvc.aspx to my routes. So instead of this:

    routes.MapRoute( _
        "Default", _
        "{controller}/{action}/{id}", _
        New With {.controller = "Home", .action = "Index", 
                  .id = UrlParameter.Optional} _
    )

I now use this:

    routes.MapRoute( _
        "Default", _
        "{controller}.mvc.aspx/{action}/{id}", _
        New With {.controller = "Home", .action = "Index", 
    )

This works at getting MVC to work on older versions of IIS. However, when I navigate to http://win2k3machine/MyMVCApplication/, I get "Directory Listing Denied" message. Similarly, when I use Casini (Visual Studio's development web server) and navigate to http://localhost:2019, I get a "Server Error in '/' Application." message.

What do I need to change in IIS and/or my MVC application to get the default page to work correctly?

NOTE: I tried adding RouteTable.Routes.RouteExistingFiles = True per this answer, but that didn't seem to fix the problem.

2 Answers 2

1

You need to add Wildcard mapping in IIS. Refer to this article for more details:

http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

This was really useful. Unfortunately, I couldn't get the Wildcard mapping to work, but everything else in the article was very helpful. Thanks!
1

I had difficulty getting Wildcard mapping to work in IIS 6. However, adding a Default.aspx page with the following code fixed the issue:

VB.NET:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) _
  Handles Me.Load
    HttpContext.Current.RewritePath(Request.ApplicationPath, False)
    Dim httpHandler As IHttpHandler = New MvcHttpHandler()
    httpHandler.ProcessRequest(HttpContext.Current)
End Sub

C#:

public void Page_Load(object sender, System.EventArgs e) 
{ 
    HttpContext.Current.RewritePath(Request.ApplicationPath, false); 
    IHttpHandler httpHandler = new MvcHttpHandler(); 
    httpHandler.ProcessRequest(HttpContext.Current); 
} 

Olders versions of IIS want to see a Default.aspx page, so this page rewrites the path to work correctly. If you get the Wildcard mapping to work in IIS, you don't need this page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.