ASP.Net 4.0 - How to change SessionState behavior through code in ASP.Net 4.0?

By [)ia6l0 iii

ASP.Net 4.0 provides the SetSessionStateBehavior method through the HTTPContext Class.

The following example shows you how to Capture the current Context and change the SessionStateBehavior.

HttpContext currentContext = (sender as HttpApplication).Context;  
currentContext.
SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Disabled);

Related FAQs

Although Application variable and a Session are server side state management techniques, they have some differences.
Named and optional parameters is a new concept introduced in 4.0. The Named Parameters allow you to pass arguments by parameter name instead of parameter position in the signature. Optional Parameters allow parameters to be specified as optional by providing a default value for them in a member declaration. When the member is invoked, optional arguments can be omitted.
Use the Override versions of the page methods instead of thedefault page methods. This would ensure that the .Net runtime does not have to invoke delegates.
You can check the contenttype of the request, and figure out if the request is an JSon request
Use the Proxy property of the Http Web Request to specify proxy.
Use the HtpContext's Request object to determine the Browser name.
ASP.Net 4.0 - How to change SessionState behavior through code in ASP.Net 4.0?  (1470 Views)