ASP.NET: How to access Session from handler?
42,895
Solution 1
Implement the System.Web.SessionState.IRequiresSessionState interface
public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Session["StackOverflow"] = "overflowing";
context.Response.Redirect("~/AnotherPage.aspx");
}
}
Solution 2
Implement IRequiresSessionState
Author by
mistertodd
Any code is public domain. No attribution required. జ్ఞా <sup>🕗</sup>🕗 Yes, i do write i with a lowercase i. The Meta Stackexchange answer that I am most proud of
Updated on July 09, 2022Comments
-
mistertodd almost 2 years
i'm trying to store some values in the Session from a Handler page, before i do a redirect to a WebForms page, that will pick up the Session values and pre-fill the WebForm:
public class Handler : IHttpHandler { public void ProcessRequest(HttpContext context) { ... context.Session["StackOverflow"] = "overflowing"; context.Response.Redirect("~/AnotherPage.aspx"); ... } ... }
Except
context.Session
object is null.How do i access Session state from a handler?