Reply
Application_BeginRequest, or Application_Start
Old 01-25-2007, 05:43 AM Application_BeginRequest, or Application_Start
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
I put the following code in an old application. I remember there was a reason I place it inside the BeginRequest instead of Start, but I can't remember why.

Can someone tell me why this needed to be in BeginRequest, and what the difference is between the two. Thanks.

Code:
 
Application_BeginRequest
{
        Thread.CurrentThread.CurrentUICulture = new CultureInfo(
            ConfigurationManager.AppSettings["CultureType"].ToString());
}
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
When You Register, These Ads Go Away!
     
Old 01-25-2007, 11:45 PM Re: Application_BeginRequest, or Application_Start
ForrestCroce's Avatar
Half Man, Half Amazing

Posts: 3,025
Name: Forrest Croce
Location: Seattle, WA
At first I was shocked this worked ... but actually that points to the difference between the two events. Basically, your application is static - there's only one instance, ever - but requests are not. By default with ASP.NET you can service 20 requests at the same time ( this is set in machine.config ).

So, the application only starts once, until it closes, then it can be started again. That's the "English language" version of the Application_Start event. But, it's a server application, that fields multiple requests from clients; it gives each request its own thread to run on. ( These live in the "thread pool" meaning when one is finished, it waits for more work to do, instead of dieing, which makes your app run faster because it doesn't have to constantly "give birth" to lots of threads. ) So the "English" version of Application_BeginRequest is that this happens when the web server ( IIS ) starts working on a request from a client, and gives it its own thread to run your code on.

That's why at first I didn't think this would work; each request is likely to be serviced by a different thread, even for the same page from the same client. But that's why you had to put your code in one event, and not the other.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 01-26-2007, 02:31 AM Re: Application_BeginRequest, or Application_Start
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Thanks
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Reply     « Reply to Application_BeginRequest, or Application_Start
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12162 seconds with 13 queries