Restarting the IIS pool, restarting the pool, restarting the application, updating web.config - global asax

I have an MVC3 web application running under IIS 7. During initialization in global.asax application scanning, all assemblies returned by BuildManager.GetReferencedAssemblies () and all kinds (Assembly.GetTypes ()) in these assemblies in order to initialize .

From time to time, the application stops working properly - it behaves as if initialization never occurred or some types were skipped during startup. When the application enters this state (I think this happens after the pool is reused), it remains so until it is restarted:

  • Manually updating Web.Config (adding spaces)
  • Manually restarting the application in IIS Manager
  • Manually stopping and starting an application pool in IIS Manager
  • Automatic restart of the pool

I noticed that 1. always helps, but 2,3,4 works indeterministically - at least, as far as I can tell, because the nature of the problem is not deterministic - the application crashes only after some planned revisions. What is the difference between 1 and 2,3,4 in terms of global.asax code and access to loaded assemblies?

Oh, the application works as a sub-application (a subfolder in the IIS tree of sites) if it changes anything.

+4
source share
1 answer

I believe that your problem can be solved by storing status information, so the application can know whether its launch was successful.

Whenever an application checks there for something incorrectly initialized, it should reinitialize it or throw an exception and restart the application.

It is very difficult to give you a solution, but to summarize, you can do this:

  • Track initialization.
  • Do not run the application in an unexpected state.
  • Double check if some unmanaged resource will not be released somewhere in your code (possibly file streams, database connections ...?).
  • Logging , logging , logging ...

Directly answering your question:

  • Restarting the application pool.
    • HttpApplication (Global.asax) fires application initialization events (start of event).
  • Restarting the application pool.
    • HttpApplication (Global.asax) fires application initialization events (start of event).
  • Basically, the application stops for the entire incoming request until you run it again. In principle, the disposal of a pool of hard applications.
    • HttpApplication (Global.asax) fires application initialization events (start of event).
  • Restarting the application pool.
    • HttpApplication (Global.asax) fires application initialization events (start of event).

In principle, any of these actions gives the same result.

Have you tried to run the IIS reset - iisreset /restart - command? This should free up any locked resource and stop any unwanted loop, thread, or something else, crashing your application.

+1
source

Source: https://habr.com/ru/post/1389243/


All Articles