如果你要保证数据的安全性,你可以在ashx中使用session验证。
如:你的index.aspx中使用jquery回调ashx数据,那么在index.aspx page_loadsession["checked"]="true",在ashx中验证session是否存在。

ashx中要获取session内容还需如下几步

①导入命名空间
实现代码如下:

using System;
using System.Web;
using System.Web.SessionState;//第一步:导入此命名空间

②实现接口

publicclassMyWeb:IHttpHandler将此改为如下:

publicclassMyWeb:IHttpHandler,IRequiresSessionState//第二步:实现接口 到此就可以像平时一样用Session了

③调用方法

HttpContext.Current.Session["Session变量名称"]

以上就是【在ashx文件中使用session的解决思路】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)

与本文相关的软件

发表我的评论

最新评论

  1. 暂无评论