Sunday, June 19, 2011

automatically detect the language set in the user's browser

Q. How can a asp.net page automatically detect the language set in the user's browser ?
Automatic detection of the language preference of the user as set in his browser
In your web.config file, you need to set the following globalization tag with the values that are presented below:
<system.web>
   <globalization
          uiCulture="auto"
          culture="auto"
          enableClientBasedCulture="true" />
</system.web>

New features in .Net 4.0

1. ASP.NET 4.0 comes with a new option for compressing the Session data with Out Process Session mode(mode=StateServer). To enable this functionality, we need to add “compressionEnabled=”true” attribute with the SessionMode in web.config.
image
When Compression mode is enabled in web.config, ASP.NET compresses the serialized session data and passes it to session storage and while retrieving same deserialization and decompression happens in the server side. ASP.NET 4.0 used System.IO.Compression.GZStream class to compress the session mode.

2. We can programmatically change Session State Behavior when required as below:


 //The Session State behaviour can be any of: Default,Disabled,ReadOnly,Required based on the requirement.

3.
HttpContext.Current.SetSessionStateBehavior( System.Web.SessionState.SessionStateBehavior.Default)