ASP.NET MVC on IIS 6 - wildcard mapping - the incoming request does not match any route

前端 未结 3 1725
孤独总比滥情好
孤独总比滥情好 2020-12-16 23:02

I have been trying to set up my Beta 1 MVC app on IIS 6 and cannot get it to run correctly. I have added a Wildcard mapping to the .net isapi DLL as suggested in other blog

相关标签:
3条回答
  • 2020-12-16 23:48

    Here's what I did to get extensionless URLs working with IIS 6 and ASP.NET MVC Beta 1.

    • Create a default ASP.NET MVC Beta project and compile it.
    • Create a new IIS website pointing to the application directory.
    • In the IIS properties for the website, click the HomeDirectory tab.
    • Click the "Configuration..." button. In the "Mappings" tab, click "Insert..."
    • Next to the "Wildcard application maps" label In the textbox, type in "c:\windows\microsoft.net\framework\v2.0.50727\aspnet_isapi.dll"
    • Uncheck the box labelled "Verify that file exists" Click OK
    • Navigate to /home It worked!

    You shouldn't need to change web.config at all. You just need to map all requests to IIS to the ASP.NET Isapi dll otherwise ASP.NET will never get those requests.

    0 讨论(0)
  • 2020-12-16 23:52

    Unfortunatly IIS 6 needs a file extension to map the request to the right handler which means you will have to use the .mvc suffix on your controller names, such as /{controller}.mvc/{action}

    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
    SimplyRestfulRouteHandler.BuildRoutes(routes);
    
    routes.MapRoute(
          "Default",
          "{controller}.mvc/{action}/{id}",
          new { controller = "Home", action = "Index", id = "" }
    );
    

    However, the are ways around this depending on your level of control on the IIS 6 server. Please refer to the following pages for more information

    • http://biasecurities.com/blog/2008/how-to-enable-pretty-urls-with-asp-net-mvc-and-iis6/
    • http://www.flux88.com/UsingASPNETMVCOnIIS6WithoutTheMVCExtension.aspx
    0 讨论(0)
  • 2020-12-16 23:55

    OK, got it working.

    The problem was that I was using msbuild automation to package up the files that I needed to deploy, and I was missing global.asax.

    So it looks like if global.asax is not deployed to the site then none of the routes get hooked up. This means that hitting the website root correctly results in the error 'The incoming request does not match any route.', and any other requests no longer get routed through to your controller classes, so result in a 404.

    HTH.

    0 讨论(0)
提交回复
热议问题