简体   繁体   English

在ASHX处理程序上恢复会话值返回Null

[英]Recover Session value on ASHX handler return Null

I have a .ASHX handler, that make some operations, and I need recover a specific information that are in the Session, so I do context.Session["key"] but always returns null the context.Session 我有一个.ASHX处理程序,该处理程序会执行一些操作,并且我需要恢复会话中的特定信息,因此我需要执行context.Session["key"]但始终将context.Session返回null。

I've try some configurations on Web.Config file like 我已经尝试对Web.Config文件进行一些配置,例如

<sessionState mode="InProc" customProvider="DefaultSessionProvider" cookieless="AutoDetect">

Or 要么

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="Session" />
      <add name="Session" type="System.Web.SessionState.SessionStateModule"/>
    </modules>
  </system.webServer>

but without success, can anyone help me recover the Session value on .ASHX handler? 但是没有成功,谁能帮助我恢复.ASHX处理程序上的Session值?

At your handler .ashx.cs code implement the interface IReadOnlySessionState 在您的处理程序.ashx.cs代码中,实现接口IReadOnlySessionState

Example: 例:

class Handler : IReadOnlySessionState { ... 类处理程序:IReadOnlySessionState {...

That will not return null but the session 那不会返回null,而是会话

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM