我是 trying to store some values in the Session from a Handler page ,在我重定向到 WebForms 页面之前,它将获取 Session 值并预填充 WebForm:
public class Handler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
...
context.Session["StackOverflow"] = "overflowing";
context.Response.Redirect("~/AnotherPage.aspx");
...
}
...
}
除了context.Session
对象为空。
如何从处理程序访问 session 状态?
最佳答案
实现System.Web.SessionState.IRequiresSessionState界面
public class Handler : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
context.Session["StackOverflow"] = "overflowing";
context.Response.Redirect("~/AnotherPage.aspx");
}
}
关于ASP.NET:如何从处理程序访问 session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1058568/