Reputation: 7601
In my application i'm defining a class which implements ihttpmodule and it contains following methods
public void Init(HttpApplication application)
{
application.EndRequest += new EventHandler(Application_EndRequest);
}
private void Application_EndRequest(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
IObjectContainer objectClient = context.Items[KEY_DB4O_CLIENT] as IObjectContainer;
if (objectClient != null)
{
objectClient.Close();
}
objectClient = null;
context.Items[KEY_DB4O_CLIENT] = null;
}
when i try to run the application and debug it, i notice one strange thing:
in chrome private void Application_EndRequest(object sender, EventArgs e) is getting executed 3 times when the application starts and again 3 times when the application ends.
in Internet explorer private void Application_EndRequest(object sender, EventArgs e) is getting executed 2 times when the application starts and again 2 times when the application ends.
Why is Application_EndRequest getting executed multiple times. Is it not supposed to run only once ?
And also i would like to know the difference between Visual Studio Development Web Server and IIS ?
What is the difference between both of me.
Please help me
Thanks in anticipation
Upvotes: 1
Views: 14083
Reputation: 40160
Application_EndRequest()
will be called as many times as there are requests handled by the runtime. With the VSDev Server, that will be -every- request; including ones for images, and other various resources the browser might look for... such as a bookmark icon image.
That could also explain the difference between the browsers; IE and Chrome may have differences in what extra things they are trying to request, particularly re: the site icon.
Upvotes: 12