Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Asp.net网站断开连接_C#_Asp.net_Login_Web Config - Fatal编程技术网

C# Asp.net网站断开连接

C# Asp.net网站断开连接,c#,asp.net,login,web-config,C#,Asp.net,Login,Web Config,我想问你这个问题,因为我有点受不了 我想知道为什么当我通过我的登录表单连接时,当我在默认页面上时,在保持连接1小时后,它会断开连接并返回登录页面 这是我真正的网络配置 <configuration> <configSections> </configSections> <connectionStrings> <remove name="LocalSqlServer" /> <add name="Loca

我想问你这个问题,因为我有点受不了

我想知道为什么当我通过我的登录表单连接时,当我在默认页面上时,在保持连接1小时后,它会断开连接并返回登录页面

这是我真正的网络配置

<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>


在表单标签中,您需要添加
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>

PingAsptokepsession();
函数PingAspToKeepSession(){
var url=“KeppSession.aspx”;
var httpOb=window.XMLHttpRequest?new-XMLHttpRequest():new-ActiveXObject('Microsoft.XMLHTTP');
打开(POST),url,true);
httpOb.send(“”);
setTimeout(“pingasptokepsession();”,60000);//每60秒
} 

表单cookie可能已过期,或者会话可能已过期,或者应用程序池可能已回收。哦,是的,没错。我还将检查应用程序池中的设置。但我想我确实花了最长的时间。