MVC routes lost after app pool recycle (updated title 3/3/14)

半腔热情 提交于 2019-12-02 06:06:25

问题


I am trying to deploy an ASP.NET MVC 4 web application to a production server (Windows Server 2008 R2 [x64] with SP1 installed, running IIS 7.5) that already has several other working ASP.NET applications. All I can get is a 403 at index, and a 404 for everything else but the static content. The application works without a problem on my local machine's instance of IIS 7.5 (And I am running on Windows 7, up-to-date, 64-bit.)

What I have tried:

  • <modules runAllManagedModulesForAllRequests="true"/>
  • Trying to apply the Microsoft hotfix for extensionless urls (found at http://support.microsoft.com/kb/980368) (Did not help, service pack 1 includes it already)
  • Ensuring that HTTP Errors, HTTP Redirection, and Static Content are added to the role services (https://stackoverflow.com/a/4264564/1030925)
  • Running the command aspnet_regiis -iru
  • Ensuring the bitness of the application is correct (Any CPU)
  • Toggling enabling of 32-bit applications
  • Toggling between classic and integrated mode
  • Ensuring that 'allow unlisted file name extensions' is checked (https://stackoverflow.com/a/5155322/1030925)
  • Ensuring that the ExtensionlessUrlHandler mappings were intact
  • Ensuring that my startup code was in Application_Start and not something else
  • Ensuring folder permissions to the ApplicationPoolIdentity (it can serve static content)
  • Re-adding the UrlRoutingModule-4.0 module in the web.config (https://stackoverflow.com/a/16577694/1030925)

UPDATE:

This morning I stopped the site, stopped the app pool, redeployed without touching anything, and... it works! BUT... if I touch so much as one little thing in the config, whether using FileZilla or the IIS console on the remote desktop, the site blows up and start acting that way again. Only by stopping the site and replacing all the files together have I been able to get it back up -- tried just stopping and replacing the web.config but that did not work. The change can be as simple as disabling and re-enabling my 'redirect to https' rewrite rule.

Update 3/3/14:

It seems as though the problem is that my routes stop working when the app pool is recycled, whether by file change or explicit restart. I am registering like two routes in the same way as the project template, using Application_Start and RegisterRoutes. I don't understand why this is not working if it's in the standard project template...


回答1:


The problem was with my publish settings. I was using the following precompile options in Visual Studio 2012:

By selecting 'do not merge' or 'merge all outputs to a single assembly', the problem was alleviated.

UPDATE:

The problem resumed even with the other settings, it just didn't happen right away. I had to disable precompiling altogether.




回答2:


I want to give my 2 cents here. I had this exact behaviour on Windows Server 2012.

My problem had nothing with configuration but the fact the global.asax was having an exception in the Application_Start and my code to register the routing table never occurred after the recycle. So if you have this behaviour, make sure you trap exceptions and handle them so all your code execute.



来源:https://stackoverflow.com/questions/22079387/mvc-routes-lost-after-app-pool-recycle-updated-title-3-3-14

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!