ashx中使用session[解决方案]

来源:互联网 发布:三联送货单打印软件 编辑:程序博客网 时间:2024/06/08 10:58

问题描述:

        在.ashx中,可以写出Session[ ],但是在使用的时候报告:对象的引用未设置到对象的实例。Object reference not set to an instance of an object.

解决方案:

         1、引入命名空间:using System.Web.SessionState;

         2、实现接口:IRequiresSessionState

完整如下:

using System.Web.SessionState;namespace ma{    /// <summary>    /// Summary description for upload    /// </summary>    public class upload : IHttpHandler,IRequiresSessionState    {    }}