简体   繁体   中英

404 Error when moving ASP.NET MVC app from IIS6 to IIS7

I just got a new development box and am having issues getting my MVC project up and running. My old box had Server 2003 and IIS6. I was able to get my MVC apps working on this box after setting up the wild card mapping as mentioned here . My new box is running Vista Business and IIS7. When I copied my app over and tried to run it, I get an 'http 404 The resource cannot be found.' error. However, if I create a new MVC app and run that, everything works fine. I also copied the Nerd Dinner app over from my old box and that works fine as well.

I've verified that the app is running in Integrated Mode and have compared the web.config files of the working and non-working apps but see nothing that is different other than application specific appsettings. I have tried to run the app in Classic Mode with the wild card mapping set, but that does not work either. I have also tried running the app using Cassini, but got the same results.

I have posted the answer on my blog, check it out at

http://nkitdugar.blogspot.com/2011/02/special-care-while-migrating-mvc.html

I had a MVC based application that was earlier hosted on IIS 6. Now IIS 6 doesn't support extensionless URL routes by default, so we need to add some extension to the controller name in the default route defined like {ControllerName}.aspx{Action method}{Id} in IIS6. Also we if we wanted to go for some other extensions like .mvc etc. then we needed to map it using techniques like wildcard mappngs etc.

Now when we have migrated to IIS7, then extensionless URLs are supported which means URLs can be there which don't have any corresponding physical location.

So when you are migrating your MVC application to IIS7 then make sure the default route define in Globla.asax don't have any extension defined with controller like {controller}.aspx\\{action method}\\{Id} and change it to \\clean URL route {Controller}\\{Action Method}\\{ID(optional)} . Second thing you should keep in mind that the pipeline mode of AppPool of the website should be set to Integrated from classic.

That's all now your website is ready to be hosted on IIS7.

OK, I figured out the problem. The App in question is a port of a Web Forms app over to MVC as a proof-of-concept project. As such, when the project was first created, we just added a .MVC to the end of the project name to make it {project name}.MVC. This, not surprisingly now that I know what's going on, caused a problem with the default routing definitions. I changed the name to use an underscore instead of a period and everything works now. I'm assuming that it worked fine while running under IIS6 since it was setup using a wild card mapping and therefore there was no .MVC extension to confuse it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM