简体   繁体   中英

IIS Precache App Pool Events

We have a pretty large asp.net LOB web application. The problem is that every time the app pool is started (whether its the first time, or if the app pool is recycled) it's takes up to 10 seconds or more to spin up and hit the first page. This leaves you in a state of looking at a white page and a loading spinner until IIS is ready to serve up the page. This isnt the end of the world because it's only normally a one off thing and only the first person experiences this. I'm just wondering if there is an event that we can hook into to serve up a page and show the user some type of simple splash screen to give them some type of feedback instead of a loading state.

Has anybody got any ideas on how to hook this into IIS/asp.net?

You can use the application initialization module. If you run IIS 8.0 or higher it is built-in, if you run IIS 7.5 you can download and install it.

Hopefully you are running .NET 4.5. Set the application start mode to AlwaysRunning. Then enable preload.

And then here you will want to add this to your web.config in your system.WebServer section

<applicationInitialization remapManagedRequestsTo="Startup.htm" skipManagedModules="true" >
    <add initializationPage="/default.aspx" />
</applicationInitialization>

The startup.htm is your default loading screen. If anyone tries to access it when they go to the web application it will be remapped to that. Just add a simple JavaScript refresh location script to it.

This link should give you everything you need. Again, I am assuming you are on a newer version of ASP.NET and IIS.

http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization

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