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

1.在aspx和aspx.cs中,都是以 Session["type"]="aaa" 和 string aaa=Session["type"].ToString() 进行读写。而在一般处理程序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();


猜你喜欢

转载自blog.csdn.net/Mj_kk/article/details/75086699