简体   繁体   English

会话超时无法更改

[英]Session timeout could not be changed

I have asp hosting in myasp.net, I tried to change the session timeout 24h but still the server disconnected users after several minutes. 我在myasp.net中托管了asp,我尝试更改会话超时24h,但是几分钟后服务器仍然断开了用户的连接。 I tried to use c# code like: 我试图使用C#代码,例如:

Session.Timeout = 3600; Session.Timeout = 3600;

It is how web.config look like: 这就是web.config的样子:

    <?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appSettings>
    <add key="owin:AutomaticAppStartup" value="false"/>
  </appSettings>

  <system.web>
     <sessionState mode="InProc" cookieless="false" timeout="80" />
    <authentication mode="Forms">
      <forms timeout="60" />
      </authentication>

    <trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime executionTimeout="180" targetFramework="4.5" maxRequestLength="13107200" />
  <customErrors mode="Off" />
  </system.web>
<system.webServer>
    <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Is there a solution to this problem? 有解决这个问题的方法吗?

Session.Timeout is not the only thing you should care of. Session.Timeout不是您唯一需要关心的事情。 IIS has a recycle timeout usually set to 20 minutes, that causes an Application Pool to release its memory after that time. IIS的回收超时通常设置为20分钟,这将导致应用程序池在该时间之后释放其内存。 You should change that too. 您也应该更改它。

As another recommendation, consider using StateServer instead of InProc , and also setting debug to false (in production environment of course) to have a more reliable session experience. 作为另一项建议,请考虑使用StateServer而不是InProc ,还可以将debug设置为false (当然,在生产环境中)以获得更可靠的会话体验。

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

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