Asp.net网站断开连接
我想问你这个问题,因为我有点被这个问题困扰。
我想知道为什么当我通过登录表单进行连接时,当我在默认页面上时,保持连接 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您正在使用 ASP.Net 表单身份验证。默认超时为 30 分钟(半小时),我很惊讶它可以让您空闲一个小时。
使用以下代码来控制超时时间。
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.
那是因为您的
Session
超时。您可以阅读此处了解此问题以及解决方法它
That's because your
Session
gets timed out.You can do some reading here on this issue and ways of fixing it
在表单标记中,您需要添加
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.这是我用来避免会话过期的一个小 JavaScript
this is a small javascript i'm using to avoid session to expire