首页 > Web开发 > 详细

ASP.Net一般处理程序Session用法

时间:2019-07-28 19:32:29      阅读:84      评论:0      收藏:0      [点我收藏+]

1.在aspx和aspx.cs中,都是以 Session["type"]="aaa" 和 string aaa=Session["type"].ToString() 或使用

HttpContext.Current.Session[strSessionName] = strValue;进行读写。

而在一般处理程序ashx中,Session都要使用context.Session,读写方法不变。

2.在ashx文件中,若要对Session进行成功的读写,要添加命名空间和接口,否则context.Session["type"]读出的总是null。

命名空间:using System.Web.SessionState

增加接口:IRequiresSessionState

代码如下:

 

public class pagingQuery : IHttpHandler, IRequiresSessionState

string type =context.Session["type"].ToString();

ASP.Net一般处理程序Session用法

原文:https://www.cnblogs.com/qqhfeng/p/11260159.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!