Ajax.Net在后台调用Session和Cookie比较特殊,需要使用如下的写法:

 

Cookie:
HttpContext.Current.Response.Cookie[key]

Session:
HttpContext.Current.Session[key]

 

此外,要使用Session还需要在AjaxMethod特性后加Ajax.HttpSessionStateRequirement参数:

 

 

[Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
public string GetInfo(string a)
{
//do something
}

 

HttpSessionStateRequirement枚举有:None,Read,ReadWrite,根据你的需要选用即可。

相关文章:

  • 2021-09-03
猜你喜欢
  • 2022-02-24
  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2021-10-06
  • 2021-11-26
相关资源
相似解决方案