By default, the generic application class inherits the IHttpHandler interface to allow programming of HTTP requests. The IHttpHandler interface defines a method: ProcessRequest (HttpContext context) and a property isreusable.
Context. Session state is read-only and if you want to manipulate it, implement the IRequiresSessionState interface under the System.Web.SessionState namespace. The IRequiresSessionState interface is a markup interface, and there is no method that enables the specified destination HTTP handler to have read and write access to the session-state value.
Using System;
Using System.Web;
Using System.Web.SessionState;
public class Test:ihttphandler,irequiressessionstate
{
public void ProcessRequest (HttpContext context)
{
Context. Response.ContentType = "Text/plain";
Context. Response.Write ("Hello World");
Context. session["UserID"] = 1;
}
public bool IsReusable
{
Get
{
return false;
}
}
}
Original: http://www.cnblogs.com/morsh/archive/2009/11/04/1596140.html
Create a session in a generic application