Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Forms Authentication Redirect cause Anchor loss

So here is the problem.

I use Anchors as a non-refreshing way to allow bookmarking of currently view objects.

http://myserver/showobject.aspx#objectid=10

I use this so when updating the object id it doesn't try to do a refresh on the page.

Heres the rub.

I am using forms Authentication to handle access to these pages. So When you try to browse to the above link without having logged in first, it redirects you to the login page. Once you have been successfully authenticated it FormsAuthentication.RedirectFromLoginPage(...) you to the page you came from.

Except that it trunks the #objectid=10 bit off.

I have thought up a few hacks (set a cookie before the redirect to the login page and then read the cookie and update the link after the "RedirectFromLoginPage" is done) for getting around this, but was wondering if there was any real way to make FormsAuthentication.RedirectFromLoginPage do what i actually want it to do.

So recap:

  • Trying to goto http://myserver/showobject.aspx#objectId=10

  • Redirected to login

  • Current/Wrong Behavior: redirected after login to http://myserver/showobject.aspx - sans #objectId=10

  • Future/Right Behavior: redirected after login to complete original url, http://myserver/showobject.aspx#objectId=10

Thanks for the assist in advance,

John.

like image 780
Giggy Avatar asked Jul 31 '09 20:07

Giggy


2 Answers

temporary cookie is the way to go here. web browsers don't send anything after the "#" when telling the server which URL they are being referred from - so the server can't capture that info and know to use it after the user signs in

like image 94
Robert Levy Avatar answered Oct 23 '22 13:10

Robert Levy


That part of the URL is called a fragment and doesn't get seen by the server side. There are hacky ways around it using an interstitial page and a bit of javascript, but it can get messy.

like image 39
Francis Gilbert Avatar answered Oct 23 '22 12:10

Francis Gilbert