Jeeva J
Jeeva J

Reputation: 3253

Set/Change/Update current culture dynamically c#

I am trying to change the current culture in web api throuch c#.net. I've tried in web forms and asp.net mvc also, but didn't work

After I go through some answers from Stack overflow, I've found the following answer to change the current culture.

  CultureInfo.CurrentCulture.ClearCachedData();
     System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo(Code);
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo(Code);

But after I update, the culture has been changed for the current request only. After sending another request from the application, the culture info has been changed to default one.

I don't know what's happening. I want to maintain the current culture for the application till the user log out.

How to implement this one?

Upvotes: 2

Views: 1823

Answers (1)

SaphuA
SaphuA

Reputation: 3140

You can override Application_BeginRequest in your Global.asax file to change the culture on each request.

Edit: Technically not an override. More here: how do you wire up Application_BeginRequest() in asp.net-mvc

Upvotes: 1

Related Questions