【问题标题】:How to redirect to custom page when form authentication timed out?表单身份验证超时时如何重定向到自定义页面?
【发布时间】:2013-09-16 16:03:43
【问题描述】:

当网站表单验证超时时,我可以重定向到自定义页面而不是 Login.aspx 页面吗?我在 web.config 中使用以下代码进行了非常标准的表单身份验证。

<forms loginUrl="Login.aspx" timeout="25" slidingExpiration="true" cookieless="UseCookies" defaultUrl="Default.aspx"/>

   <customErrors mode="On" defaultRedirect="ErrorPage.aspx">
      <error statusCode="401" redirect="TimedOutErrorPage.aspx" />
   </customErrors>

   <location path="TimedOutErrorPage.aspx">
    <system.web>
        <authorization>
            <allow users="?"/>
        </authorization>
    </system.web>
 </location>

我尝试使用 401 statusCode 出现自定义错误,但它没有按我预期的那样工作。它总是回到 Login.aspx。

【问题讨论】:

    标签: asp.net vb.net http-status-code-401 form-authentication


    【解决方案1】:

    当您的会话超时时,在服务器端它是已知的,但客户端(即浏览器)不知道会话究竟何时过期,出于任何原因,因此在下一个请求之前不会处理任何内容通过做一些活动来完成。届时会发现会话已过期,然后尝试重新登录。

    因此,我们的想法是开发一种解决方案,该解决方案将在客户端(浏览器)上跟踪超时值,并对服务器端进行适当的更新。使用客户端脚本将服务器超时与客户端超时同步。

    然后,您可以向用户显示有关会话即将到期的警告/通知,并强制他们与之交互。详细阅读this article。

    【讨论】:

      猜你喜欢
      • 2011-09-15
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 2019-06-30
      • 2013-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多