Asp.net网站断开连接

发布于 2025-01-05 21:06:14 字数 1489 浏览 3 评论 0原文

我想问你这个问题,因为我有点被这个问题困扰。

我想知道为什么当我通过登录表单进行连接时,当我在默认页面上时,保持连接 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>

我应该在网络配置中添加其他内容来禁用此功能吗?

有点烦人..

I would like to ask you this question because I am a bit stuck with it .

I'm wondering why when I connect thanks to my login form, and when I am on my default page, after 1h staying connected, it disconnects and goes back to the login page.

This is my actual 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>

Should I put something else in the web config to disable this ?

It's a bit annoying ..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

难以启齿的温柔 2025-01-12 21:06:14

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

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

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

You are using the ASP.Net forms authentication. The default timeout for which is 30min (half an hour) I am surprised it lets you idle for an hour.

use the following code to control the timeout period.

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

陪你搞怪i 2025-01-12 21:06:14

那是因为您的 Session 超时。

您可以阅读此处了解此问题以及解决方法它

That's because your Session gets timed out.

You can do some reading here on this issue and ways of fixing it

红ご颜醉 2025-01-12 21:06:14

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

In the forms tag you need to add slidingExpiration=true so that if the user is active within the hour the user won't be logged out. The reason they get logged out is because the session times out and by using sliding expiration the session will be extended for the session time each time the user makes a request.

醉生梦死 2025-01-12 21:06:14

这是我用来避免会话过期的一个小 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>

this is a small javascript i'm using to avoid session to expire

<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>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文