Thursday, August 13, 2015

asp.net-use Session in .ashx handler

Following is the technique to use Session in .ashx handler:

public class DownloadHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
    public void ProcessRequest(HttpContext context)
    {
      string Name = "";
      if (context.Session["UserName"] != null)
         Name = context.Session["UserName"].ToString();
    }
}


Interface used:  IRequiresSessionState this interface is in System.Web.SessionState and Session will be available in context.Session["UserName"]

No comments:

Post a Comment