views:

416

answers:

2

Hello, in my ASMX WS Application_Start is called when 1st request arrives. It's kind of too late then for me. Is there any way to get it called when iisreset is done?

In http://stackoverflow.com/questions/1820770/what-is-the-right-way-to-spawn-thread-for-database-io-in-asmx-web-service I asked about preloading system data and the guys advised me to make load in Application_Start. However if it's done only on 1st request, it's the same and thus the advise of no use at all.

Thanks!

br: Matti

A: 

If you have the newest, latest IIS 7.5, you might want to check out the Application Warm Up that was just recently added. I personally haven't used it, but it looks like it might have some of the things you need.

Overview

IIS Application Warm-Up for IIS 7.5 Beta 1 enables IT Professionals to improve the responsiveness of their Web sites by loading the Web applications before the first requests arrive. By proactively loading and initializing all the dependencies such as database connections, compilation of ASP.NET code, and loading of modules, IT Professionals can ensure their Web sites are responsive at all times even if their Web sites use a custom request pipeline or if the Application Pool is recycled.

Benefits:

Decrease the response time for first requests by pre-loading worker processes IIS Application Warm-Up allows IT Professionals to configure the Web application to be pre-loaded at the start of the Web server before the first request arrives. By pre-loading the application, the worker process is able to reduce the time it takes to respond to the first Web request. The loading and initialization of the dependencies such as database connections, .NET Framework, and the just-in-time compilation for ASP.NET applications and dependencies have already been performed by the time the request arrives to the server.

Increase reliability by pre-loading worker processes when Overlapped Recycling occurs The response times for the first requests in an Overlapped Recycling scenario are reduced by also pre-loading dependencies. The recycled worker process will only communicate its readiness and will start accepting requests after it finishes loading and initializing the resources as specified by the configuration.

Customize the pre-loading of applications IIS Application Warm-Up can be configured to initialize Web applications by using specific Web pages and user identities. This makes it possible to create specific initialization processes that can be executed synchronously or asynchronously depending on the initialization logic. In addition, these procedures can use specific identities in order to ensure a proper initialization.

Jarrett Meyer
i'm sorry. i forgot the version. i'm using IIS version 5.1 and 6.0. is there anything I can do?
matti
if it's not possible in earlier versions it's preposterous. i think the need has been there from version 0.1 since almost all the applications have some kind of initializations tasks.
matti
Most such initialization tasks can take place on the first request.
John Saunders
thanks! of course they can but that delays the request. i really can't think of any situation where request that takes longer is better than request that takes shorter time ;)
matti
A: 

You can create a simple program to make a dummy request to your web service. This will trigger Application_Start the first time.

Run this simple program as a scheduled task, running when the computer starts.

John Saunders
thanks John! I thought that also. Problem is that servers are never turned of. I'm really amazed that there is no way to make initializations beforehand... do you think there is any way to schedule anything based on IIS start?
matti
Yes, there is. In IIS 7.5. Make sure your Management know about this reason to upgrade. Then, maybe they'll upgrade in a year or so.
John Saunders