11

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

2
  • How are you retrieving the culture data after a user has it set?
    – ZippyV
    Commented Feb 20, 2013 at 12:59
  • I wold read it from a cookie. so "en-US" would be pulled from a cookie
    – ShaneKm
    Commented Feb 20, 2013 at 16:27

2 Answers 2

23

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.

3
  • Good answer. So you could say (simplified): Culture in Session -> Application_AcquireRequestState / Culture in Cookie -> Application_BeginRequest.
    – isepise
    Commented Dec 11, 2017 at 8:59
  • But what about Controller.BeginExecuteCore (i have a BaseController in my ASP.NET MVC 5 Project)? I used this to set my culture (saved in cookie)
    – isepise
    Commented Dec 11, 2017 at 9:05
  • Just a gut feeling, but it sounds weird to me to use something with "core" in it. The link in the other answer describes the whole life cycle, I'm sure there's a sufficient hook included.
    – Jan
    Commented Dec 11, 2017 at 12:53
8

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.