I have a scenario where I need to send the user to the login page, with the returnurl parameter populated with the page they're currently sitting on including a url fragment, so as when they complete login, they're redirected back to their original page and the page scrolls down to a specific #location.
At present, it's all working except that the url fragment is lost when the returnUrl
param reaches the Login
ActionMethod.
Is there a way to retain this url fragment so it doesn't get lost during the login phase? I can see the #fragment in the url on the login page, but it appears to be stripped off when I look at the value of 'returnUrl' in my login method.
Is there a way to retain this url fragment so it doesn't get lost during the login phase?
No, there isn't. The url fragment is never sent to the server. One possibility is to modify the returnUrl on the client before passing it to the server so that the url fragment becomes part of the query string. Then when the login succeeds and the server needs to redirect back to the returnUrl it would modify it to the original value.
For example it might look like this before sending it to the Login method:
http://example.com/admin/index?fragment=somefragment