【问题标题】:ASP.NET redirecting to a page other than the default redirect urlASP.NET 重定向到默认重定向 url 以外的页面
【发布时间】:2010-06-29 06:43:32
【问题描述】:

在 asp.net 中,我们在使用表单身份验证时指定重定向 url,如下所示:

<authentication mode="Forms">
            <forms name="myApp" loginUrl="Login.aspx" protection="All" defaultUrl="default.aspx" path="/" requireSSL="false"/>
        </authentication>

这意味着当用户登录时,会被重定向到“default.aspx” 使用这种方法

FormsAuthentication.RedirectFromLoginPage(IDTextBox.Text, RememberCheckBox.Checked);

现在可以让用户在登录之前选择要重定向到的页面吗?

例如,用户在登录之前从列表中选择要登录的页面,然后在通过身份验证时重定向到该页面而不是 default.aspx 页面。

这可能吗?如果可以,怎么做?

【问题讨论】:

    标签: asp.net forms-authentication


    【解决方案1】:

    您可以使用SetAuthCookie 方法而不是使用RedirectFromLoginPage 方法,然后手动重定向:

    FormsAuthentication.SetAuthCookie(IDTextBox.Text, RememberCheckBox.Checked);
    Response.Redirect("some url the user has choosen");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-26
      • 2017-07-18
      • 1970-01-01
      • 1970-01-01
      • 2012-09-11
      • 2013-03-11
      • 2012-05-10
      • 2021-11-14
      相关资源
      最近更新 更多