超时和会话超时问题 [英] timeout and session timeout issue

查看:152
本文介绍了超时和会话超时问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有超时的问题。

首先超时发生,每20分钟就即使在webconfig的时间设定为120分钟服务器

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

第二,当发生超时它去到​​登录页面,这是正确的,但在重新登录它有时会去的默认页,有时页面是previously上。我希望它去的默认页每次。就像如果多数民众赞成这个问题应该删除所有会话和饼干。

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

这是什么,是有我的webconfig。

This is what is there in my webconfig.

推荐答案

我的理解是,你描述的设置ASP.NET不允许您的网站未认证的网络访问。
这意味着,当你去你WebForm1.aspx的重定向到登录页面与此网址

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

   }

此重定向回无论RETURNURL规定。

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

    }

这篇关于超时和会话超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆