asp.net 会话超时问题
我的 ASP.NET MVC 项目在几分钟后就超时了。这特别烦人,因为我有一个相当复杂的上传和导入过程,当我注销时,这个过程就会失败。我目前使用 asp.net 会员资格提供程序进行身份验证。
我尝试了一些我在这个网站和其他网站上看到的东西,但没有成功。这是我到目前为止在 Web 配置中的内容:
<location path="Admin/Upload">
<system.web>
<httpRuntime executionTimeout="1200"/>
</system.web>
</location>
<system.web>
<sessionState mode="InProc" timeout="20" cookieless="false" />
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="20" />
</authentication>
<add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="Server=SERVERNAME;Database=DBNAME;User Id=USER;Password=PASSWORD;timeout=30;MultipleActiveResultSets=True" />
在添加 sessionstate 超时之前,我确定在超时之前只有一分钟,然后将其增加到 2 分钟,但不能是 100%。
我考虑过使用这个:
<lifetime leaseTime="15M"/>
...但不是 100% 确定如何实现它 - 任何人都取得了成功,或者知道我可以尝试其他什么?
谢谢
编辑:我使用云托管解决方案,但只有一个控制面板 - 无法访问 IIS
更新:我现在尝试添加生命周期租赁时间,但没有任何区别:
<system.runtime.remoting>
<application>
<lifetime leaseTime="20M" />
</application>
</system.runtime.remoting>
</configuration>
更新 2: 好的,我已经编辑了标题和网络配置值以反映我的最新成果,但我仍然在挣扎。我与托管公司交谈,他们将连接超时设置为 20 分钟。但是,会话会在 10 分钟后结束。还有什么我可以尝试的吗?
我马上就到了,但我想要 20 分钟!
got a problem with my asp.net mvc project timing out after only a couple of minutes. It's especially annoying because I've got quite a complex upload and import procedure which falls over when i get logged out. I currently use asp.net membership provider for authentication.
I've tried a few things that I've seen on this site and others but to no avail. Here is what I have so far in the web config:
<location path="Admin/Upload">
<system.web>
<httpRuntime executionTimeout="1200"/>
</system.web>
</location>
<system.web>
<sessionState mode="InProc" timeout="20" cookieless="false" />
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="20" />
</authentication>
<add name="ConnectionString" providerName="System.Data.SqlClient" connectionString="Server=SERVERNAME;Database=DBNAME;User Id=USER;Password=PASSWORD;timeout=30;MultipleActiveResultSets=True" />
I was sure it was only a minute before being timed out before I added the sessionstate timeout, then it was upped to 2 mins, but can't be 100%.
I thought about using this:
<lifetime leaseTime="15M"/>
...but not 100% sure how to implement it - anyone had any success with it, or know something else I could try?
Thanks
EDIT: I'm on a cloud hosting solution, but only have a control panel - no access to IIS
UPDATE: I've now tried adding lifetime leasetime and it's not made any difference:
<system.runtime.remoting>
<application>
<lifetime leaseTime="20M" />
</application>
</system.runtime.remoting>
</configuration>
UPDATE 2:
Ok, I've edited the title and the web config values to reflect my latest effort, but I'm still struggling. I spoke to the hosting company who set the connection timeout to 20 minutes. However, it the session ends after 10 mins. Is there anything else I can try?
I'm getting there, but I would like 20 minutes!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
生命周期租用时间标签位于应用程序标签中。
我从来没有真正使用过它,但如果它像其他超时一样,我不知道你是否需要最后的 M 。但这纯粹是猜测。您还应该能够将其设置为“0”,以便其生命周期“永远”
至于会话超时,看起来应该设置为 100 分钟。但是,它应该位于您的
标记EDIT 内
与问题完全无关。但我喜欢你的运行时执行超时“超过 9000”
The lifetime leasetime tag goes in the application tag.
I've never actually used it but if it is like other timeouts idk if you will need the M at the end. That is pure speculation though. You should also be able to set it to "0" so that its lifetime is "forever"
As for the session timeout that looks like it should be set for 100 minutes. However, it should be inside of your
<configuration>
tagsEDIT
Completely unrelated to the question kind of. But i like how your runtime execution timeout is "over 9000"
是的,我找到了解决方案,但这不是我所期望的。
事实证明我错误地使用了 aspnet Membership Provider。我使用的就像我之前使用的会员系统一样,登录后将 UserId 设置为会话变量,并在整个站点中使用它。然后我发现这是错误的使用方式,并将其更改为
User.Identity.IsAuthenticated
和Membership.GetUser().ProviderUserKey
的组合。它不再超时,一切都很好。不管怎样,谢谢。
Right, I got a solution to this, but it wasn't what I was expecting.
It turned out I was using the aspnet Membership Provider wrongly. I was using like a previous membership system I worked on and logging in then setting the UserId as a session variable and using that throughout the site. I then discovered that is the incorrect way to use it, and changed it to a combination of
User.Identity.IsAuthenticated
andMembership.GetUser().ProviderUserKey
.It no longer times out and all is well. Thanks anyway.