Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to identify an iisreset in an asp.net web application?

Tags:

asp.net

iis

I've got an application that needs to do some work on startup (before the first request is in). I've added the initialization code in the global.asax file (Application_start method) but this code doesn't seem to be hit after an iis reset is performed. Is there an event which is triggered in an asp.net application when an iis reset has occurred?

Thanks.

like image 294
Roy Avatar asked Dec 27 '10 14:12

Roy


1 Answers

Application start happens on first request, not on iisreset.

The site doesn't start itself..

See "Restart cache item callback on web process restart" here.

In such cases, the service will stop running unless a page is hit and the Application_Start is called. Application_Start is called only when a page is visited for the first time in a web project.

I would suggest having a batch file that contains iisreset and an "iexplore mypage" call

Edit: apparently, you can use application end to trigger application start. YMMV

like image 108
gbn Avatar answered Sep 20 '22 20:09

gbn