how to get Application_Start (in Global.asax.cs) to be called before requests in asmx web service on IIS 6.0

妖精的绣舞 提交于 2019-12-24 00:52:39

问题


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


回答1:


If you have the newest, latest IIS 7.5, you might want to check out the Application Initialization 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.




回答2:


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.



来源:https://stackoverflow.com/questions/2047906/how-to-get-application-start-in-global-asax-cs-to-be-called-before-requests-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!