我在myasp.net上有asp托管,我试图在24小时内更改会话超时但是几分钟后服务器仍然断开了用户连接。 我尝试使用c#代码,如:
Session.Timeout = 3600;
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>
这个问题有解决方法吗?
答案 0 :(得分:0)
Session.Timeout
并不是你应该关心的唯一事情。 IIS的回收超时通常设置为20分钟,这会导致应用程序池在此之后释放其内存。你也应该改变它。
作为另一项建议,请考虑使用StateServer
代替InProc
,并将debug
设置为false
(当然,在生产环境中),以获得更可靠的会话体验