使用表单身份验证,如何处理重定向到不同的子域
我有多个使用表单身份验证的子域。用户登录后,他们就可以访问任何其他子域。
这是我的问题:如果我访问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 前面添加域并执行简单的重定向。
它有效,但感觉很笨拙。有什么想法吗?
I have multiple sub-domains that use forms authentication. Once a user logs in, they are fine going to any of the other sub-domains.
Here is my problem: If I go to reporting.example.com/reporting.aspx, I get redirected to login.example.com/login.aspx. After entering my credentials, I get redirected to login.example.com/reporting.aspx, which doesn't exist.
I have a work around but I would like to know if there is a cleaner way. What I do currently is set the loginUrl attribute of the forms element of the reporting.example.com to be login.example.com/login.aspx?domain=reporting.example.com.
Then, in the login.aspx code, after I've authenticated and set the cookie, I look to see if there was a domain variable passed in to the URL. If so, I prepend the returnUrl with the domain and do a simple redirect.
It works, but it feels klugey. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ReturnURL 是否包含完整的 url?如果是这样,它应该按预期工作。.
确保您有
Does the ReturnURL contain the full url? If so it should work as expected..
Make sure you have EnableCrossAppRedirects set to true in your web.config.