在ashx中获取不到session的值,报错“未将对象引用至实例”
解决方案
1.在ashx文件中引入命名空间 using system
using System.Web.SessionState;
2.在ashx类上继承接口
public class MaterialHandler : IHttpHandler,System.Web.SessionState.IRequiresSessionState
3.进过上面的两步你就可以在ashx文件里取到session的值了
写法一:context.Session["XXX"]
写法二:HttpContext.Current.Session["XXX"]