ASP.NET 表单身份验证默认重定向 [工作] 和使用查询字符串重定向到请求的页面 [不工作]

发布于 2024-08-10 11:02:30 字数 825 浏览 1 评论 0原文

我有一个网站,基本的表单身份验证工作正常。用户的电子邮件包含指向我的网站的链接,并带有查询字符串变量。系统会提示用户正确登录,但使用

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

停顿的约定 2024-08-17 11:02:30

不幸的是,这是设计使然,但这里有一篇关于这个问题的精彩文章描述了它,并提供了解决方法:

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 to FormsAuthentication.GetRedirectURL() and adding in the correct querystring.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文