Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Application_Start of Global.asax is called by iis on wcf application when the iis is the host ?

I have wcf application that is hosted by iis. I add the Global.asax file with implimentation of the Application_Start.

But when i start the iis ( or reset ) i don't see that the Application_Start method is called.

How to fix it ? I want that the iis will call this method on iis start (when the computer startup ( because the iis start automatic on machine start ) or when iis restart )

like image 773
Yanshof Avatar asked Feb 09 '17 20:02

Yanshof


2 Answers

If the WCF Service is hosted on the IIS on a website, then the Application_Start Method should be called. However, by default application pool wouldn't start until the Application Pool receive the first request.

So, until you make a call to WCF Service, the Application_Start method wouldn't be called.

Also, IIS offer Application Initialization Module, which can be used to issue a Fake Request to the website by the IIS Server so that Application can start Automatically once the IIS Starts. It also allows for custom warm-up code for the Application. You can read more detail here.

like image 97
Abhinav Galodha Avatar answered Nov 11 '22 21:11

Abhinav Galodha


WCF doesn't work like that. It's a per-call service and as so handling requests on demand...

A little more details can be found here: https://stackoverflow.com/a/739674/444665

However you might be able to solve your wish through this solution Running a function on WCF start up

like image 3
woodbase Avatar answered Nov 11 '22 20:11

woodbase