【问题标题】:asp.net timeout of page页面的asp.net超时
【发布时间】:2013-05-20 06:56:11
【问题描述】:

我在下面有一个超时,想确保它正常工作:

我的 web.config 文件中有以下内容:

<system.web>
    <authentication mode="Forms">
     <forms loginUrl="SVideo/Login.aspx" timeout="2" slidingExpiration="true" />
    </authentication>
    <authorization>
        <allow users="*" />
    </authorization>
</system.web>

对于登录页面,我有以下代码(请注意,我使用的是 asp.net 附带的登录控件:

protected void LoginUser_LoggedIn(object sender, EventArgs e)
{        
   var roles = Roles.GetRolesForUser(LoginUser.UserName);

   if (roles.Contains("StUser"))
   {
      const string url = "~/SVideo/WatchLive/Watstream.aspx";
      Response.Redirect(url);
   }
   else
   {
      lblMessage.Text = "Wrong UserName/Pwd Combination";
   }
}

更新:请注意,在 SVideo 文件夹中,我确实有以下代码:

在 SVideo 里面我有以下代码:

    <?xml version="1.0"?>
    <configuration>
     <system.web>
       <authorization>
        <allow users="*" />            
      </authorization>
     </system.web>
    </configuration>

在 SVideo/WatchLive 我有以下代码:

    <?xml version="1.0"?>
    <configuration>
    <system.web>
    <authorization>           
        <allow roles="StUser" />
        <deny users="*" />
    </authorization>
    </system.web>
   </configuration>

我的问题是,当用户在被验证为 StUser 角色的一部分后转到 Watstream.aspx 时,我希望页面在没有活动后 2 分钟后超时,因为这是我所拥有的超时.相反,即使在 2 分钟后,我也没有收到超时消息。

另外请注意,我的目标实际上是让它在 2 天后超时,但我这样做只是为了确保 2 分钟它可以达到我的预期。

【问题讨论】:

  • 您在 SVideo 和 SVideo/WatchLive 文件夹中是否有任何web.cofig 授权?或者除了主 web.config 之外的任何授权?
  • 是的,Win 是对的,您可能需要确保拒绝匿名用户...
  • @Win - 嗨,Win,在单独的文件夹中有 web.config。我更新了我上面所做的。

标签: asp.net authentication timeout


【解决方案1】:

要触发超时,您必须回发到服务器。

试试这个:

  1. 在 Watstream.aspx 上放置一个按钮并将 onclick 事件绑定到回发到服务器
  2. 登录网站
  3. 在 Watstream.aspx 页面上等待 3 分钟,然后单击按钮
  4. 如果你做的一切都正确,你应该被重定向到你的登录页面,

另外,如果这不起作用,请清除浏览器中的所有 cookie,然后重试

【讨论】:

    猜你喜欢
    • 2011-04-25
    • 2010-12-26
    • 2012-06-18
    • 2012-01-30
    • 1970-01-01
    • 1970-01-01
    • 2012-06-26
    • 2013-06-07
    • 2017-09-07
    相关资源
    最近更新 更多