6

Normally, I use App_Offline.htm for taking the site offline. But occasionally, when I do that, the site just hangs (like in: browsers wait forever, server gives no response at all). This seems to happen on an updateable site when I change something, like a control and afterward, when it doesn't go quick enough (site hangs), I place App_Offline.htm in the root of the website.

In most cases, this immediately takes down my site. But occasionally it doesn't. In those cases, I cannot just stop the website (when I restart, the behavior continues). Stopping the application pool doesn't let me restart the same app pool. The only two solution so far is restarting the whole IIS web service.

I'd like to prevent this from happening. Is this a bug in IIS not "breaking all actions" when App_Offline.htm is found? I use IIS 7 with Windows 2008 SP2 64 bit.

Abel
  • 56,041
  • 24
  • 146
  • 247
  • Do you have threads that you open, and database access ? – Aristos Aug 23 '10 at 07:17
  • @Aristos: I don't manually open threads, but any web application has multiple threads, of course. Yes, I have database access. In this particular site, the connection is centralized in a (thread-safe) singleton and data is retrieved through NHibernate. But I was under the impression that App_Offline.htm should take down *all* threads by force, no? – Abel Aug 23 '10 at 07:21
  • Just a minute ago, had the exact same situation: I replaced a DLL, site takes forever to respond, app_offline.htm doesn't work and taking down the site takes some time (but helps). – Abel Aug 23 '10 at 07:31
  • @Abel yes threads are force to stop - I just make a test now and they force to stop. – Aristos Aug 23 '10 at 08:37
  • @Abel one point to check is the Application_End on global.asax – Aristos Aug 23 '10 at 08:39
  • @Aristos: Your hint on `Application_End` is interesting, there's some clean up code: the `LogManager` (log4net) is shutdown and a message is written to the eventlog to indicate shutting down. But the log isn't big (daily logs under 50MB). I'll remove the eventlog line see if that helps. – Abel Aug 23 '10 at 08:45

6 Answers6

8

What I found was that my web.config file either had an error in it or was missing. When this is the case, app_offline.htm does not get processed.

GolfARama
  • 787
  • 6
  • 8
4

IIS should not stop existing actions, only prevent new requests from going through: Will app_offline.htm stop current requests or just new requests?

It sounds like you are describing a scenario where you update a control, try to load a page, and IE is stuck loading. At this point you drop the app_offline.htm and expect to see that page immediately.

If you are making a completely separate/new request after putting app_offline.htm in place then you should see the page come up. However the existing request will not be affected as linked above.

If possible try deploying the app_offline.htm file prior to making the control change.

Community
  • 1
  • 1
Matt Glover
  • 1,347
  • 7
  • 13
  • 2
    It turned out (many, many of these situations later), that this was most closely to the real cause. Existing actions, especially on a busy site, can take a _long_ time to stop, even more so if any of these actions happen to be in the midst of a GC-cycle and memory is scarce (causing the GC to take up more time). – Abel Mar 10 '11 at 12:18
1

I am not sure what you mean by "Stopping the application pool doesn't let me restart the same app pool"...if you meant that you can't restart the pool immediately after stopping it, thats because it isn't stopped yet. Depending on the number of Worker Processes in that pool it may take a min for it to completely spin down so it can accept the start command.

Also, I would think you would have to restart the pool in order for the app_offline.htm to work effectively anyway.

Max_Steve
  • 416
  • 1
  • 5
  • 6
  • +1 for restarting the pool, it helps, but only sometimes (restarting IIS is more dramatic, but works more often when things have gotten unresponsive). – Abel Mar 10 '11 at 12:19
0

Here's the thing. Everytime when you open the .sln at the server, or updating the code, it will create the app_offline ticket in the root. This is the feature from asp.net itself to prevent any access to disturb your development.

Delete the app_offline manually everytime after you open the .sln.

hope this help. thanks.

yene
  • 9
  • 1
  • You should never have the SLN files on your production server. I think you are referring to publishing the site with Visual Studio, which indeed uses app_offline.htm. This question is about how it is possible that even with `app_offline.htm` in place, the site is not made offline (i.e., is not redirecting to `app_offline.htm`). – Abel Dec 21 '12 at 12:04
0

Another possibility is a missing handler. The following handler is required:

ExtensionlessUrlHandler-Integrated-4.0
Robert Sirre
  • 672
  • 1
  • 8
  • 28
0

To fix the issue you need to at a minimum:

  • Wait the length of your website timeout to ensure all requests have finished.
    • Background processes kicked off from a web request will mean further extending the length of time you wait beyond the website timeout
  • Unload any unmanaged code by hooking into the DomainUnload or Application_End events

I'm waiting 3 minutes for App_Offline.htm to take affect and this seems has allowed App_Offline.htm to work as expected.