Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

global.asax Application_AcquireRequestState vs. Application_BeginRequest

what is the difference? I would like to implement Language dropdown selection in my app. So when a selected language is selected, a Thread culture would be set and page reloaded.

Like so:

Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");

where should settings like above be processed? Application_AcquireRequestState or Application_BeginRequest?

thanks

like image 694
ShaneKm Avatar asked Feb 20 '13 08:02

ShaneKm


2 Answers

It depends on the way you are saving your language across requests. If you are using a session to save your selected language in, you should use Application_AcquireRequestState, because since Application_BeginRequest is earlier in the life cycle, the session state object might not yet be available at this time.

like image 52
Jan Avatar answered Oct 06 '22 21:10

Jan


Application_BeginRequest occurs earlier in the lifecycle and is the 'usual' place this goes.

http://msdn.microsoft.com/en-us/library/ms178473%28v=VS.100%29.aspx

like image 25
Adam Tuliper Avatar answered Oct 06 '22 21:10

Adam Tuliper