.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

Executing code when web application starts

Hi,
I'm working on a web application (actually on some web services). I need to implement some mechanism that will allow me to execute some code when web application is started/stopped - this executed code will publish information about application status (to some external service). This web application will be installed to IIS (5.0, 6.0).

The solution should ensure that this code is automatically executed, it's not accepted that some action is required to trigger it (for example opening some page). I wonder if IIS allows to do something like that, I've been looking for solution for some time, but for now I have this feeling that it can be tricky.

BTW
I would appreciate any links/references to good articles, books about IIS advanced topics - like internals, filters,  configuration. There's a lot of articles about creating simple web apps, but the more you want to get from IIS the less documentation you find ;-))
Pawel Niewiadomski Send private email
Wednesday, January 24, 2007
 
 
I know you're looking for something internal to IIS, but have you considered writing a Windows Service that monitors the web service(s)? You could call a function in the web service every 60 seconds to monitor from a real world point of view.

If you only execute monitoring code when a web application starts and stops you may miss the true long term status of the application. Monitoring external to the hosting application takes into consideration hanging, configuration problems, general network health, etc.

In IIS 6.0 you could monitor the application pool if you have a separate pool for your application.
Mike Saeger Send private email
Wednesday, January 24, 2007
 
 
If this is .Net then the Global.asax file has Application_Start and Application_End. 

You can add code in those events to log the launching of the app.  Now this won't tell you exactly when the app comes up, just the first request to it.

But maybe that's good enough?
tjk Send private email
Wednesday, January 24, 2007
 
 
Sorry, I just reread the bit about no triggers.
tjk Send private email
Wednesday, January 24, 2007
 
 
How do you "start a web application"? http://www.google.ca/search?hl=en&q=iis+start+application suggests http://www.iisworks.com/faq/kb.asp?a=show&ID=164 which implies that an application is run when you:

a) Start IIS
b) Install the application into a virtual directory
c) Navigate to the virtual directory

If by "start application" you mean "start IIS", there are tons of ways to see when IIS is started (e.g., I don't know, by reading the NT Event Log, using the Service Control Manager API to query the state of the IIS service, or by reading the relevent Performance Counter).
Christopher Wells Send private email
Wednesday, January 24, 2007
 
 
I didn't think about writing additional service that would monitor my web services. I wanted to do this from inside of IIS. The idea is that the web application will handle multiple web services that will be installed inside of it. There are some actions that must be performed when web application is starter or stopped. I don't care if IIS hangs or crashes as long as it's automatically started again (and my web application).

I found Global.asax before, read documentation. The problem with Application_Start is that it's called only when the first resource of the web application is accessed. So it will not be called when IIS is started. I thought that IIS is in its nature is more lika a containter (something like Tomcat?) not a simple web server. But seems to me now that I was wrong.

I will try to look for something that looks more like a container (is like Tomcat for .NET) for ASP.NET applications or I will have to end up with some additional windows services that will monitor IIS, etc.
Pawel Niewiadomski Send private email
Thursday, January 25, 2007
 
 
How about using Microsoft Scheduling Agent that runs an app when another app runs? MSA can be activated for a preset time or day or when an application runs or when Windows starts or shuts down. I use it to run my backup batch file using its time and date settings. Check it out.
Ezani Send private email
Thursday, January 25, 2007
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz