473,804 Members | 3,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Store flag in cache/session on BeginRequest event

Hello,
On BeginRequest event I check and set user language settings. First I
check for browser's accepted languages and set Cultureinfo. If
browserlanguage is not supported, CultureInfo is set to a predefined
defaultvalue (en-US).
However, a visitor must be able to manualy change the language
settings. This is done by querystring-parameter.

Above works great, but whenever the next page is loaded, CultureInfo is
reset to browserlanguage . I can't find a way to store a bool value,
indicating browserlanguage/default language has been set before. I
tried the Runtime Cache, but this doesn't seem to be persistant.

TIA

###

This is what my code looks like ...

private void context_BeginRe quest(object sender, EventArgs e)
{

HttpRequest request = ((HttpApplicati on)sender).Requ est;

// browser language
if (request.Server Variables["HTTP_ACCEPT_LA NGUAGE"] != null)
{
_httpAcceptLang uage =
request.ServerV ariables["HTTP_ACCEPT_LA NGUAGE"];
}

// check for manual language-switch
NameValueCollec tion queryString = request.QuerySt ring;
LoadCulture(ref queryString);

}

private void LoadCulture(ref NameValueCollec tion qstring)
{
if (qstring != null && qstring["lan"] != null)
{
try
{
Thread.CurrentT hread.CurrentCu lture = new
CultureInfo(qst ring["lan"].Trim());
}
catch
{
this.LoadDefaul tCulture();
}
finally
{
setCulture();
}
}
else if ( HttpRuntime.Cac he["BrowserLanguag eIsSet"] == null )
{
// if no language is set, try to set browser language
// unsupported browserlanguage will load default
if (_httpAcceptLan guage != string.Empty)
{
setBrowserLangu age();
}
else
{
this.LoadDefaul tCulture();
}
HttpRuntime.Cac he.Insert("Brow serLanguageIsSe t", true, null);
setCulture();
}
}

Nov 17 '05 #1
0 2031

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4142
by: Joakim Westman \(Elicit AB\) | last post by:
Hi! I have a page that generates a lot of HTML, and I am considering different solutions to constrain the amount of code that is sent back to the client. One thing I thought about is the viewstate which is fairly large for this application. Does anybody have any experience on storing viewstate in Session.
2
1958
by: NWx | last post by:
Hi, Is Cache appropriate to store persistent variables used across the application? What I want is to store UserID for currently logged user, SessionID (my own SessionID, which keep track of datetime for login and logout as well as other info, like Client IP , etc) My objects I want store to cache are not set-up to expire. Or should I store them better in Session storage?
0
1328
by: Michael O'Brien | last post by:
I'm trying to hook in a specialized state store server into ASP.NET. I understand I can create a HttpModule and hook the events OnAcquireState and OnReleaseState. So far so good. But, it seems that the framework owns the HttpSessionState instance (HttpContext.Session) and so my state store module must use the Add, Remove and Clear methods to interact with the store. ie. on Acquire, I need to call HttpSessionState.Add to add all the...
18
6885
by: Rippo | last post by:
Hi I am using role base forms authentication in asp.net and have come across a problem that I would like advice on. On a successful login a session variable is set to identify a user. This is all good as this session variable is used to retrieve data for that user etc. However if I restart the webserver then the users session is lost but the ticket is still active. Therefore the user is not redirected back to the login page.
7
2115
by: Shadow Lynx | last post by:
I realize that his question has been asked, in many other forms, many times in this group. Even so, my tired eyes have not yet found a sufficient answer, so I've decided to "reask" it even though I'm sure this will offend some of the more seasoned verterans of this board. The Players: Consider a simple web form, which I'll call Page A, that has a couple of controls on it. It's not important what they are, only that they're static...
8
2589
by: graphicsxp | last post by:
Hi, I'm trying to figure out the best way to redirect the user to a special page when in my code i'm trying to use a Session object and that one is nothing. Oviously I could do: if Session("myObject") is nothing then response.redirect("SessionExpired.aspx") else endif
11
3036
by: john_c | last post by:
I'd like to store information for roles in Session variables. RoleA has a specific set of values, RoleB has a specific set and so one. When I access values for RoleA, it looks like this: Session = "30" Session = "1000" Session = "5" Session = "10" and similar for the other roles. Those values are initially loaded
2
4753
by: Sobin Thomas | last post by:
Hi All....... I am a beginner in asp.net.I need your help.I have a gridview control in my Default.aspx page.I use data adapter to fill a datatable and then I set the datasource of the gridview as the datatable.The datatable obtained is a large one.I want this table to be in memory(I dont know how to),as I have to use the same datatable for enabling paging in gridview. In short,my problem is ,I need to store the datatable (which is filled...
5
6803
by: =?Utf-8?B?Y2hlY2tyYWlzZXJAY29tbXVuaXR5Lm5vc3BhbQ== | last post by:
I have a site which I secure with forms authentication. When the user's sign on and hit one of the secure pages, I have this line in my code to ensure that the browser does not cache the page; and someone cannot navigate back to an cached image of the page in theory after the user has signed off. Response.Cache.SetCacheability(HttpCacheability.NoCache); This works all right, except when the user decides to use the browser's back...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10323
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.