我正在尝试在m项目中实现会话。在检索密码和验证后,我将emailadd
发送给处理程序通过Ajax Call。这是setsession
public class setsession : IHttpHandler, System.Web.SessionState.IRequiresSessionState
{
public void ProcessRequest(HttpContext context)
{
string email = (context.Request.QueryString["email"]);
context.Session["Emailadd"] = email;
context.Response.ContentType = "text/plain";
}
public bool IsReusable
{
get { return false; }
}
}
在此之后我将我的页面重定向到第二页,并在页面的开头用ajax调用我试图检索存储的电子邮件添加。这是代码
public void ProcessRequest(HttpContext context)
{
JavaScriptSerializer js = new JavaScriptSerializer();
var email2 = context.Session["Emailadd"];
context.Response.Write(js.Serialize(email2));
context.Response.ContentType = "text/plain";
}
public bool IsReusable
{
get { return false; }
}
但是从此页面返回的值为NULL。我错过了什么?在此先感谢。