locked
Global Resources: Using the Strongly Typed Class for multi-language web application RRS feed

  • Question

  • User-1965130617 posted

    I've got a multi-culture website using asp.net 2.0 localization. I have a Global Resource that I created that contain various Email Subjects and Body that get set out using the Membership Providers. I've been getting some complaints that some emails are sent out in the wrong language...

    The way I have it set up is, the user language is set inside a cookie which is read in the Global's Application_BeginRequest method, that sets the CurrentThread's Culture and UICulture. Then in the SendingMail methods of both the CreateUserWizard and ForgotPassword I create an email by using the Auto-Generated Strongly Typed class for my Email Global Resource.

     Resources.Emails.MyEmailBody

    I took a look at this class and noticed that it uses a shared Field for both the resourceCulture (cultureInfo) and the resourceMan (ResourceManager)

    Could this mean that each thread is using the same shared fields and causing a request that is in english to be calling the french resx values ?

    Should I be using the GetGlobalResource instead or setting the Resources.Emails.Culture property before calling my resources ?

    Any help would be appreciated

    Thursday, October 18, 2007 4:38 PM

Answers

  • User-503940700 posted

    Hi,

    Using a global shared (static in C#) is not a good idea as it would be shared across different requests. You should use a cookie or a Session object for this.

    Hope this helps,

    Vivek 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 19, 2007 3:48 AM