cookies:
ashx端赋值:
context.Response.Cookies["Username"].Value = "";
后台端加载:
Response.Write(Request.Cookies["Username"].value);
session:
ashx端赋值三部:
using System; using System.Web; using System.Web.SessionState;//第一步:引用命名空间 //第二步:实现接口 public class Login : IHttpHandler, IRequiresSessionState { public void ProcessRequest(HttpContext context) { string un = context.Request["uname"]; string pwd = context.Request["pwd"]; string json = "{"ok":"0"}"; Users u = new UsersData().Select(un, pwd); if (u != null) { context.Session["user"] = un;//第三步:实现Session赋值 json = "{"ok":"1"}"; } ...
后台端加载:
Response.Write(Session["user"]);