如果你要保证数据的安全性,你可以在
ashx
中使用
session
验证。
如:你的
index
.
aspx
中使用
jquery
回调
ashx
数据,那么在
index
.
aspx page_load
时
session
[
"checked"
]=
"true"
,在
ashx
中验证
session
是否存在。
但
ashx
中要获取
session
内容还需如下几步:
①导入命名空间
using
System
;
using
System
.
Web
;
using
System
.
Web
.
SessionState
;
//第一步:导入此命名空间
②实现接口
public
class
MyWeb
:
IHttpHandler
将此改为如下:
public
class
MyWeb
:
IHttpHandler
,
IRequiresSessionState
//第二步:实现接口 到此就可以像平时一样用Session了
③调用方法
HttpContext
.
Current
.
Session
[
"Session变量名称"
]