【问题标题】:Using forms authentication, how do I handle redirection to a different subdomaim使用表单身份验证,我如何处理重定向到不同的子域
【发布时间】:2011-01-27 15:43:44
【问题描述】:

我有多个使用表单身份验证的子域。一旦用户登录,他们就可以进入任何其他子域。

这是我的问题:如果我转到reporting.example.com/reporting.aspx,我会被重定向到login.example.com/login.aspx。输入我的凭据后,我被重定向到不存在的 login.example.com/reporting.aspx。

我有一个解决方法,但我想知道是否有更清洁的方法。我目前所做的是将reporting.example.com 的forms 元素的loginUrl 属性设置为login.example.com/login.aspx?domain=reporting.example.com。

然后,在 login.aspx 代码中,在我验证并设置 cookie 之后,我查看是否有一个域变量传入 URL。如果是这样,我会在 returnUrl 前面加上域并进行简单的重定向。

它有效,但感觉很糟糕。有什么想法吗?

【问题讨论】:

  • 这几乎是最好的方法。否则,您唯一的其他实际选择是与推荐人合作,他们的可靠性约为 10%。

标签: asp.net subdomain formsauthentication


【解决方案1】:

ReturnURL 是否包含完整的 url?如果是这样,它应该可以按预期工作..

确保在 web.config 中将 EnableCrossAppRedirects 设置为 true。

【讨论】:

  • 不幸的是,returnUrl 是相对于调用应用程序的主目录的。在我的示例中,returnUrl 是 /reporting.aspx。
  • 看起来这段代码会将完整的 URL 放入 RedirectURL:weblogs.asp.net/dfindley/archive/2007/02/06/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-01
  • 1970-01-01
相关资源
最近更新 更多