开发者

ASP.NET Forms Authentication Default Redirect [Working] and Redirect to Requested Page w/QueryString [Not Working]

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜