There was a post 3 months ago asking essentially my question, but I’m reposting as no answers came back that can handle my scenario. Issue is that when forms authentication redirects to the login page in ASP.NET, the hash portion of the URL is lost (since it is never sent to the server), so after login, the user is not directed to the correct location. It was suggested that the user could store off the hash value at the time the user is redirected, but in my case that won’t work because the user is accessing the page from a link in an email, and the redirect happens not in my code, but automatically due to the web.config forms configuration. Any thoughts how I can allow users to be directed to the correct hash-based deep link after login?
Here’s the existing post: .net IE8 hash url redirect
Here’s a post on how someone solved for the same browser behavior in Java: http://forum.springsource.org/showthread.php?101421-Preserving-URL-anchor-when-redirecting
Thanks!
The following workaround fixes the issue:
1) In email link, include a querystring variable that contains an encoded version of the hash address, AND include the hash address contents
2) In login page’s server side code, read the route and use it to append the hash portion to the returnUrl that the login page will redirect to after login: