繁体   English   中英

Asp.net网站断开

[英]Asp.net website disconnection

我想问你这个问题,因为我对此有些坚持。

我想知道为什么我要借助登录表单进行连接,以及当我位于默认页面上时,保持连接1小时后,它将断开连接并返回登录页面。

这是我实际的webconfig。

<configuration>
  <configSections>
  </configSections>
  <connectionStrings>
    <remove name="LocalSqlServer" />
    <add name="LocalSqlServer" connectionString='Data Source=.\SQLEXPRESS; AttachDbFilename = "C:\Users\Maxime\Documents\Visual Studio 2010\Projects\ClientPortal\ApplicationUI\Website\ClientPortal\App_Data\DataUi.mdf";Integrated Security=True;User Instance=True'
       providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <pages validateRequest="false" />
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"  />
    <authentication mode="Forms">
      <forms loginUrl="Logon.aspx" name=".ASPXFORMSAUTH">
      </forms>
    </authentication>
    <authorization>
      <deny users="?" />
      <allow users="*" />
    </authorization>
    <sessionState cookieless="false"/>
    <httpRuntime maxRequestLength="1048576"/>
  </system.web>
  <appSettings>
    <add key="FolderPath"  value="uploads" />
  </appSettings>  
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
  </system.serviceModel>
</configuration>

我是否应该在Web配置中添加其他内容以禁用此功能?

有点烦..

您正在使用ASP.Net表单身份验证。 默认超时为30分钟(半小时),我很惊讶它使您闲置了一个小时。

使用以下代码控制超时时间。

<system.web>
<authentication mode="Forms">
      <forms timeout="50000000"/>
</authentication>

那是因为您的Session超时。

你可以做一些阅读这里对这个问题修复它和方式

在表格标签中,您需要添加slidingExpiration=true这样,如果用户在一个小时内处于活动状态,则不会注销该用户。 他们注销的原因是,会话超时,并且通过使用滑动到期,每次用户发出请求时,会话将被延长会话时间。

这是一个小JavaScript,我正在使用以避免会话期满

<script type="text/javascript">
    PingAspToKeepSession();
    function PingAspToKeepSession() {
    var url = "KeppSession.aspx";
    var httpOb = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
    httpOb.open("POST", url, true);
    httpOb.send("");
    window.setTimeout("PingAspToKeepSession();", 60000); // every 60 seconds

    } 
    </script>

暂无
暂无

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

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