IIS 5 & IIS 6
Global.Application_BeginRequest not fired on concurrent request
Last post Feb 11, 2009 08:32 AM by nicdex
Feb 04, 2009 10:07 AM|nicdex|LINK
Version of IIS: 5.1 (xp) and 6.0 (Windows Server 2003)
My application initialize his database provider in the beginrequest, but when we are doing concurrent request, the BeginRequest event is not fired up in the global.asax so the connection is not working.
What I mean by concurrent request is when there is two requests running simultanously on the web server. Example: page1 is still loading, and page2 starts loading. In this case, page2 doesn't fire BeginRequest and will crash because the database provider
is not initialized.
This problem doesn't occur on the VS2005 WebDev.Server.
Is this behavior normal or not and why?
Thanks for your help.
BeginRequest not firing concurrent request
Feb 11, 2009 03:01 AM|Leo Tang - MSFT|LINK
The BeginRequest event signals the creation of any given new request. This event is always raised and is always the first event to occur during the processing of a request. Hence, the BeginRequest event not being fired up is b-normal behavior.
In this case, we need try to determine if the BeginRequest is really not being fired up or is the database provider not being initialized.
I’d suggest you debug your deployed website by attach to the “w3wp.exe” process to verify this. You can debug your website on IIS by using the following steps:
1.Open your website ‘s source code in the Visual Studio
2.Deploy you website on IIS, view a page of your website to active a w3wp.exe work process
3.Select the w3wp.exe process to debug(Visual Studio->Tools->Attach to process)
4.Set a break point at the beginning of the BeginRequest event function
5. Press F5 to start debugging
If you don’t want to debug your website on the server machine. You can add the statement “System.Diagnostics.Debugger.Break()” to the BeginRequest event function to see if the BeginRequest event is raised. When the statement “System.Diagnostics.Debugger.Break()”
is executed , a debug inquire window will be popup. To do this, you need set the application pool identity as local system temporary to obtain debug privileges.
Please make sure the “debug="true" “ in the section “compilation” of the web.config file
Additionally, you can get more valuable suggestions at our
Feb 11, 2009 08:32 AM|nicdex|LINK
I did debug the BeginRequest event, by adding a break point at the beginning of my BeginRequest function. It didn't fire for the concurrent request on IIS, but it did in the WebDev.Server.
I also added an HTTPModule to add logging on every possible event fired by an HTTPRequest. What I noticed is that on the concurrent request the first event fired up is the AcquireRequestState (wich is the 9th in the event list in the MSDN HTTPApplication
After this, I moved my db initialization code to the PreRequestHandlerExecute function, and it worked, because it is always executed.
But still, it bugs me... because I think it's an IIS problem.