超时和会话超时问题

发布于 2024-09-26 19:23:36 字数 607 浏览 3 评论 0原文

我遇到超时问题。

首先,即使 webconfig 中的时间设置为 120 分钟,服务器上每 20 分钟就会发生一次超时。

其次,当超时发生时,它会转到登录页面,这是正确的,但重新登录时有时会转到默认页面,有时会转到之前所在的页面。我希望它每次都进入默认页面。如果这是问题的话,它应该删除所有会话和 cookie。

<authentication mode="Forms">
 <forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" name="GUI"   slidingExpiration="true" timeout="120" path="/">
</forms>
</authentication>
 <authorization>
 <deny users="?"/>
    <allow users="*"/>
 </authorization>

<sessionState mode="InProc" cookieless="false" timeout="120"/>

这就是我的 webconfig 中的内容。

I have a problem with timeout.

firstly the timeout happens every 20 minutes on server even if the time in webconfig is set to 120 mins.

second, when the timeout happens it goes to the login page, which is correct but on logging back in it sometimes goes to the default page and sometimes to the page it was previously on. I want it to go to the default page everytime. Like it should remove all the sessions and cookies if thats the problem.

<authentication mode="Forms">
 <forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" name="GUI"   slidingExpiration="true" timeout="120" path="/">
</forms>
</authentication>
 <authorization>
 <deny users="?"/>
    <allow users="*"/>
 </authorization>

<sessionState mode="InProc" cookieless="false" timeout="120"/>

This is what is there in my webconfig.

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

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

发布评论

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

评论(4

赢得她心 2024-10-03 19:23:36

这可能与您的具体问题相关,也可能无关,但进程内用户会话将无法在应用程序回收后继续存在。在 IIS 中检查您的应用程序回收时间是否足够长。如果应用程序保持活动状态,您的会话确实可能会持续 120 分钟,但一旦闲置时间过长,您的应用程序就会回收,并且您的用户会话将变得无效。

This may or may not be related to your specific issue, but in-proc user sessions will not survive application recycles. Check in IIS that your application recycle time is sufficiently high. Your sessions may indeed last 120 minutes if the application remains active, but once it idles for too long, your app will recycle and your user sessions will become invalidated.

前事休说 2024-10-03 19:23:36

我的理解是,通过您描述的设置,ASP.NET 不允许未经身份验证的 Web 访问您的站点。
这意味着当您转到 WebForm1.aspx 时,您将被重定向到具有此 url 的登录页面

/login.aspx?ReturnUrl=%2fWebForm1.aspx

然后在您的登录页面中您可能会看到类似这样的内容

    protected void LoginButton_Click(object sender, EventArgs e)
    {

        if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))
            FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text,false);
        else
           // Let the user know they didn't authenticate

   }

这将重定向回 ReturnUrl 指定的任何内容。

好吧,如果您不希望这种情况发生,请不要这样做。而是做这样的事情。

    protected void LoginButton_Click(object sender, EventArgs e)
    {

        if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))
            Response.Redirect("default.aspx");
        else
           // Let the user know they didn't authenticate

    }

My understanding is that with the setup you described ASP.NET doesn't allow unauthenticated web access to your site.
This means that when you go to WebForm1.aspx you get redirected to the login page with this url

/login.aspx?ReturnUrl=%2fWebForm1.aspx

Then in your login page you might have something like this

    protected void LoginButton_Click(object sender, EventArgs e)
    {

        if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))
            FormsAuthentication.RedirectFromLoginPage(UsernameTextbox.Text,false);
        else
           // Let the user know they didn't authenticate

   }

This redirects back to whatever the ReturnUrl specifies.

Well if you don't want that to happen don't do that. Do something like this instead.

    protected void LoginButton_Click(object sender, EventArgs e)
    {

        if (FormsAuthentication.Authenticate(UsernameTextbox.Text, PasswordTextbox.Text))
            Response.Redirect("default.aspx");
        else
           // Let the user know they didn't authenticate

    }
独守阴晴ぅ圆缺 2024-10-03 19:23:36

你好
看一下iis中的应用程序池,检查高级设置->进程模型->空闲超时(分钟)。将其设置为高于 20 分钟。听起来工作进程正在关闭,因为它处于空闲状态。测试系统经常会发生这种情况,因为它们没有获得足够多的命中来阻止空闲超时的发生。

欢呼 Tigger

Hi
Take a look at the application pool in iis, check the advanced settings->process model->idle timeout (minutes). Set this higher than 20 mins. Sounds like the worker process is shutting down because its idle. Often this happens with test systems because they don't get that many hits to stop the idle timeout from kicking in.

Cheers Tigger

醉生梦死 2024-10-03 19:23:36

检查以下事项:

  • 您的 web.config 中确实有 120 分钟的时间吗?
  • 这是您唯一的 web.config 吗?如果不是,它是否从正确的位置获取这些值?
  • 使用 fiddler(或类似工具)检查您的浏览器是否仍在请求 cookie(尤其是 20 分钟后)

Check the following things:

  • You've definitely got 120 mins in your web.config?
  • Is this your only web.config? If not is it picking these values up from the correct place?
  • Use fiddler (or similar) to check your browser is still requesting with a cookie (especially after 20 mins)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文