`
ruilinruirui
  • 浏览: 1050703 次
文章分类
社区版块
存档分类
最新评论

启用ashx的session

 
阅读更多

ashx中默认不能使用session, HttpContext.Current.Session为null。

解决方法如下

实现接口System.Web.SessionState.IRequiresSessionState即可,代码如下:

using System;

using System.Web;

public class BoundaryHandler : IHttpHandler, System.Web.SessionState.IRequiresSessionState{

public void ProcessRequest (HttpContext context) {

context.Response.ContentType = "text/plain";

context.Response.Write("Hello world");

}

public bool IsReusable {

get {

return false;

}

}

}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics