session ID. You would get the error message "Session State is not available
in this Context" if the SessionStateModule failed in this process.
"Edge" wrote:
> hi Phillip,
>
> Thanks for the reply.
> I should not put this in a cookie, some browsers/users might not
> support/want it and I decided not to used. So I load a session variable with
> the user language that I get from the DB after his login.
> Right now, this is working in my global.asax file, but I get an exception
> (but the application won't break) when the user hits the first page, than
> after that is all good.
>
> So...the problem still persists, how can I set the current culture for a
> logged user without having to set in every single page the page culture?
>
>
> -E
>
>
> "Phillip Williams" <Phillip.Williams@webswapp.com> wrote in message
> news:0B18AF34-F454-472B-BEFD-616C08753EB2@microsoft.com...
> > If you add Culture="auto" UICulture="auto" to the page directive and an
> > American user logs when his/her browser setting is "en-US" then they would
> > not need to select the language of their preference unless they want to
> > switch to a language that is not in the first selection in their browser
> > setting. You can then add a link that says "Select language of
> > preference"
> > which would save the selection in a cookie and upon next visit the master
> > page would simply execute Page.Culture=selectedCulture if there were a
> > cookie. This would last longer than using the Session object which
> > expires
> > when the browser is closed or the Session expired (in which scenario the
> > user
> > has to select the culture upon every visit)
> > --
> > HTH,
> > Phillip Williams
> >
http://www.societopia.net > >
http://www.webswapp.com > >
> >
> > "Edge" wrote:
> >
> >> hi Phillip,
> >> because for example, in a chinese cybercafe I want a american user to
> >> login
> >> in our system and be able to choose his preferred language just once and
> >> then this selection to be applied in all the other pages.
> >> I tried your suggestion but, I do not want to put in every single page
> >> code
> >> like Page.Culture = "en-us".
> >>
> >> -E
> >>
> >>
> >>
> >>
> >> "Phillip Williams" <Phillip.Williams@webswapp.com> wrote in message
> >> news:433466A6-D313-4ACC-A9E9-E073B38C24EB@microsoft.com...
> >> > Why not use the user's browser settings upon each postback instead?
> >> > You
> >> > can
> >> > set Culture="auto" UICulture="auto" on the page directive, e.g.:
> >> >
http://www.webswapp.com/CodeSamples/aspnet20/AutoCulture.aspx > >> > --
> >> > HTH,
> >> > Phillip Williams
> >> >
http://www.societopia.net > >> >
http://www.webswapp.com > >> >
> >> >
> >> > "Edge" wrote:
> >> >
> >> >> hi,
> >> >> I am saving the user selected culture in a session variable so I can
> >> >> apply
> >> >> it back to all pages when refreshed and then load the proper .resx
> >> >> values.
> >> >> For that I am using global.asax, Application_AcquireRequestState,
> >> >> because
> >> >> every page load will execute this method.
> >> >> Even thou it works, very often I get en exception telling that the
> >> >> session
> >> >> can not be retrieved in this context.
> >> >>
> >> >> What's the best place to actually place this verification in order to
> >> >> be
> >> >> reflected in every page of my application?
> >> >> here the global.asax code
> >> >>
> >> >> public void Application_AcquireRequestState(object sender, EventArgs
> >> >> e)
> >> >> {
> >> >>
> >> >> if ( Session["myculture"] != null )
> >> >> {
> >> >> string currentCulture = (string)Session["myculture"];
> >> >> if (String.Compare(currentCulture,
> >> >> System.Threading.Thread.CurrentThread.CurrentCulture.ToString(),
> >> >> StringComparison.OrdinalIgnoreCase) != 0)
> >> >> {
> >> >> try
> >> >> {
> >> >>
> >> >> System.Threading.Thread.CurrentThread.CurrentCulture
> >> >> =
> >> >> System.Globalization.CultureInfo.CreateSpecificCulture(currentCulture);
> >> >> }
> >> >> catch
> >> >> {
> >> >>
> >> >> System.Threading.Thread.CurrentThread.CurrentCulture
> >> >> =
> >> >> new System.Globalization.CultureInfo("en-us");
> >> >> }
> >> >> System.Threading.Thread.CurrentThread.CurrentUICulture
> >> >> =
> >> >> System.Threading.Thread.CurrentThread.CurrentCulture;
> >> >> }
> >> >> }
> >> >> }
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>