7

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 )

Yanshof
  • 9,659
  • 21
  • 95
  • 195

2 Answers2

6

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.

Abhinav Galodha
  • 9,293
  • 2
  • 31
  • 41
3

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

Community
  • 1
  • 1
woodbase
  • 169
  • 11