ASP.NET MVC 404 Errors for IIS 7 Integrated mode
Hey everyone. I am getting 404 errors when I try to access my ASP.NET MVC 2 site. I'm hosting this site using II7, and I have my site set to use the DefaultAppPool
Intergrated pipeline mode. Here's my routes, it's a pretty basic site:
routes.MapRoute(
"DefaultRoute", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional // Parameter defaults
});
routes.MapRoute(
"UploadRoute", // Route name
"Upload/{id}", // URL with parameters
new { controller = "Upload", action = "Index", id = UrlParameter.Optional
});
Attemping to go to ~/Home or ~/Upload both result in 404 errors. Browsing to just the root ~/ directory remotely causes the page to just sit and wait forever, if I try to access the root locally I get a 403.14 error. I'm stumped, I thought ASP.NE开发者_如何转开发T MVC and IIS7 running integration mode was supposed to be simple. Thanks.
First thing: The most specific routes should be at the top of declaration. Your default route should be the last to be created or all following routes will be ignored.
Back to topic: Does your DefaultAppPool runs under .NET 4.0? Maybe this link can help you? Looks more like a configuration issue of your IIS?
I had the same problem and I made sure the Default App Pool was set to .net 4 and It worked. If I chose the App pool for .net 4 classic or .net 4 integrated on the application I would get that error.. It only worked when I chose default app pool., This was on a fresh 2008 server install, nothing else installed besides MVC and Webpages framework(webmatrix). very wird. I hope this helps someone.
You might be getting caught up on a non action file like a js or css file. Add an ignore route at the beginning.
routes.IgnoreRoute("*.html|js|css|gif|jpg|jpeg|png|swf");
You can also try using the RouteDebugger and see where it is going, or not in your case http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx
Also, check to see that HTTP Redirection is enabled in IIS7.
精彩评论