Friday, August 18, 2006

Accessing Request or Session objects from class modules

When we need to use a request object from another class modules we have to use the
HttpContext.Current object. This contains all the state informations like request, session, Server, Respose etc.
Eg:
string r = HttpContext.Current.Request["MyParam"].ToString();
string s = HttpContext.Current.Session["MySessionVar"].ToString();

Note: Add "using System.Web" to the header.

No comments: