2

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...

Community
  • 1
  • 1
tuespetre
  • 1,827
  • 2
  • 18
  • 30
  • if you remote into your production server and look at web site, do you see the same thing? – vidalsasoon Feb 27 '14 at 20:46
  • Yes. In fact, only by remoting in could I see the detailed errors I pasted into my question. It just doesn't want to handle the url properly anywhere! :( – tuespetre Feb 27 '14 at 20:49
  • Just for the sack or troubleshooting. Is MVC installed correctly? Correct version of .Net? Have you tried adding deployable dependencies to the solution http://msdn.microsoft.com/en-us/library/gg286946%28v=vs.100%29.aspx ? – Brent Mannering Feb 27 '14 at 21:34
  • .NET 4.5 is installed and the app pool is set to 4, not 2. The MVC dependencies are deployed with my app (System.Web.Mvc and etc. are all in the bin folder.) – tuespetre Feb 27 '14 at 21:41
  • To commenters thus far... Please see my update in case you have any ideas about the new information. Thanks! – tuespetre Mar 04 '14 at 00:01

2 Answers2

1

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.

Zyo
  • 1,934
  • 21
  • 25
0

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

enter image description here

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.

tuespetre
  • 1,827
  • 2
  • 18
  • 30