In some cases developers decide to use application or session state variables in classes that are not code-behind classes. One of the examples of this situation is when programmer chooses to have a common class for all the web pages to do one specific job.
The following property of HttpContext class allows you to do just that:
System.Web.HttpContext.Current
The above property returns System.Web.HttpContext object for current HTTP request.
You can also have access to current Request, Context, Response, Server, and Page classes.
Example:
System.Web.HttpContext.Current.Session["Key"]="Value";
No comments:
Post a Comment