zoukankan      html  css  js  c++  java
  • 2014-08-26 解决HttpContext.Current.Session在ashx文件中出现“未将对象引用设置到对象的实例”的问题

      今天是在吾索实习的第35天。

      最近在使用HttpContext.Current.Session来获取Session["..."]的值时,常常会弹出错误——“未将对象引用设置到对象的实例”。

      所以,在网上搜索了一番,发现如下解决方法:

    1. 引用:using System.Web.SessionState;
    2. 让要用到HttpContext.Current.Session的继承IReadOnlySessionState。如:public class {ClassName}: IHttpHandler, IReadOnlySessionState{…}

      其中,“IReadOnlySessionState”——指定目标HTTP处理程序只需要具有对话访问状态值的读访问权限。

  • 相关阅读:
    Misc1
    PXE
    VCL
    pacman usage
    .vimrc的配置
    Windows Server 2012 R2
    Windows 入门杂乱无章版
    VS Code Plugins And Configuration
    「Poetize5」GF弹钢琴
    「Poetize4」上帝造题的七分钟2
  • 原文地址:https://www.cnblogs.com/IamYoung/p/3937210.html
Copyright © 2011-2022 走看看