ASP.NET 表单身份验证默认重定向 [工作] 和使用查询字符串重定向到请求的页面 [不工作]
我有一个网站,基本的表单身份验证工作正常。用户的电子邮件包含指向我的网站的链接,并带有查询字符串变量。系统会提示用户正确登录,但使用
FormsAuthentication.RedirectFromLoginPage(userName, false);
当原始 url 包含查询字符串时不起作用。
我已经尝试过这些请求,但没有被记录:
http://localhost/default.aspx -- redirect to login, then back to default OK
This is the loaded URL before login:
http://localhost/login.aspx
http://localhost/TaskDetail.aspx -- redirect to login, then back to default FAIL
This is the loaded URL before login:
http://localhost/login.aspx?ReturnUrl=%2ftaskdetail.aspx
http://localhost/TaskDetail.aspx?id=5 -- redirect to login, then back to default FAIL
This is the loaded URL before login:
http://localhost/login.aspx?ReturnUrl=%2fTaskDetail.aspx%3fTaskID%3d2464&TaskID=2464
非常感谢任何帮助。
I have a website, with basic Forms Authentication working alright. Users have emails that contain links to my site, with a querystring variable. Users are prompted to login correctly, but using
FormsAuthentication.RedirectFromLoginPage(userName, false);
Does not work when the original url contains a querystring.
I've tried these requests, without being logged:
http://localhost/default.aspx -- redirect to login, then back to default OK
This is the loaded URL before login:
http://localhost/login.aspx
http://localhost/TaskDetail.aspx -- redirect to login, then back to default FAIL
This is the loaded URL before login:
http://localhost/login.aspx?ReturnUrl=%2ftaskdetail.aspx
http://localhost/TaskDetail.aspx?id=5 -- redirect to login, then back to default FAIL
This is the loaded URL before login:
http://localhost/login.aspx?ReturnUrl=%2fTaskDetail.aspx%3fTaskID%3d2464&TaskID=2464
Any help is really appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不幸的是,这是设计使然,但这里有一篇关于这个问题的精彩文章描述了它,并提供了解决方法:
http://blogs.msdn.com/vijaysk/archive/2008/01/24/anatomy-of-forms-authentication-return- url.aspx
编辑:
抱歉,我第一次阅读该博客时认为该博客中有解决方法。尝试将
Response.Redirect
执行到FormsAuthentication.GetRedirectURL()
并添加正确的查询字符串。unfortunately, this is by design but here is a great article on this very issue that describes it, plus a workaround:
http://blogs.msdn.com/vijaysk/archive/2008/01/24/anatomy-of-forms-authentication-return-url.aspx
EDIT:
My apologies, I thought there was a workaround in that blog the first time I read it. Try doing this a
Response.Redirect
toFormsAuthentication.GetRedirectURL()
and adding in the correct querystring.