programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Monday, May 25, 2015

In Programmatically Change Session State Behavior

In Programmatically Change Session State Behavior when required:

In it is possible to change the value of session at run time. Before some time when we worked on project we want to something like that then we search this topic on web and get something like that. I thing you also get some help from this programmatically change state behavior in topic.

We can enable or disable session state either in web.config or using @Page directive’s EnableSessionState attributes.

But there was no provision to change the session state at runtime till date in ASP.NET. But using ASP.NET 4.0, we can change the session state programmatically. The .NET 4.0 Framework adds a new method SetSessionStateBehavior to the HttpContext class for ASP.NET. 

This method required SessionStatebehavior value to set the current session mode. To call SetSessionStateBehavior, simply create a new HttpModule by implementing IHttModule and hook the BeginRequest event. Most important, you can only use the SetSessionStateBehavior until the AcquireRequestState event is fired, because AcquireRequestState occurs when ASP.NET acquires the current state that is associated with the current request.

While calling SetSessionStatebehavior, you can pass the following values as SessionStatebehavior:

Default: This is the default setting which means everything works as before.
Disabled: Turned of Session Sate for Current Request.
ReadOnly: Read only access to Session State.
Required: Enabled session state for both Read and Write Access.

Other Related Post: 

No comments:

Post a Comment