会话在ASP.NET中的Handler中为null



我想在处理程序中访问"我正在继承" irequiresessionState"类"类。但是,在评估会话时,它的零件为null,但是在网页上具有价值。我不知道为什么这会发生我的处理程序守则是:

 public void ProcessRequest(HttpContext context)
{
String Name = Common.GetSessionValue("UserId").ToString() ;
// my code.........

这是我获得会话值的常见方法

 public static Guid GetSessionValue(string SessionName)
    {
        Guid returnvalue = Guid.Empty;
        if (HttpContext.Current.Session[SessionName] != null)
        {
            returnvalue = new Guid(HttpContext.Current.Session[SessionName].ToString());
        }
        else
        {
            HttpContext.Current.Response.Redirect("Login.aspx");
        }
        return returnvalue;
    }

请帮助我。预先感谢

您可以通过将值暴露于外部世界http://forums.asp.net/t/1506625.aspx/1,然后尝试使用处理程序中的值来获取该值

context.Request.Form["returnvalue"]; 

您可以在Mozilla中看到Firebug插件的裸露值

最新更新