添加一个AjaxPro.HttpSessionStateRequirement 枚举的值到你的AjaxPro.AjaxMethodAttribute中.
例如:
[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
现在你就可以像下面这样存取Session的值了:
HttpContext.Current.Session["SessionName"]="SessionValue";
HttpContext.Current.Session["SessionName"].ToString().
另外一个问题:如何在AjaxMethod中使用Cookie?
答案是不能使用"this"的引用存取cookie ,你必须使用HttpContext.Current
例如:
HttpContext.Current.Request.Cookies[Name].Value.
添加 Cookie
System.Web.HttpCookie newcookie=new HttpCookie("CookieName");
newcookie.Value = "CookieValue";
newcookie.Path="/";
newcookie.Expires = DateTime.Now.AddDays(1);
HttpContext.Current.Response.AppendCookie(newcookie);
strResult = HttpContext.Current.Request.Cookies["CookieName"].Value.Trim();
清除 Cookie
System.Web.HttpCookie newcookie=new HttpCookie("CookieName");
newcookie.Expires = DateTime.Now.AddDays(-1);
newcookie.Values.Clear();
HttpContext.Current.Response.Cookies.Add(newcookie);