title: Getting the # route in from the Request in a controller in ASP.Net MVC
body: <p>I have an ASP.Net MVC web site using Forms authentication, with the loginUrl set to a Url which is used for authentication in the web.config.  The login process calls the login controller which goes through a SSO process where it does a redirect etc and the log process works correctly the user can login etc.  As part of the login process I use the returnUrl to send the user to the page they initially requested.  Or the default if none is specified.</p>
  
  <p>If the user types in a Url to another page such as <a href="http://mysite/help" rel="nofollow noreferrer">http://mysite/help</a> the returnUrl is as expected /help.  However if the user enters a url containing a hash route like <a href="http://mysite/#/test/123" rel="nofollow noreferrer">http://mysite/#/test/123</a> the returnUrl is simply / . Is it possible to get the full url with the #/test/123 from within the controller?</p>
  
  <p>To isolate this problem I created a simple ASP.Net MVC web project that demonstrates this behavior and as you can see the # route is missing when the controller is called:</p>
  
  <p>Here is the web.config:</p>
  
  <p><img src="https://i.stack.imgur.com/W2En2.png" alt="web.config"></p>
  
  <p>Here is the request in the browser:</p>
  
  <p><img src="https://i.stack.imgur.com/1yS9C.png" alt="enter image description here"></p>
  
  <p>Here is the debug view of the test application where you can see the ReturnUrl is just / and the RawUrl just has the querystring.</p>
  
  <p><img src="https://i.stack.imgur.com/0Gkfw.png" alt="enter image description here"></p>
  
  <p>Here is the same in fiddler:</p>
  
  <p><img src="https://i.stack.imgur.com/jbmZQ.png" alt="enter image description here"></p>
  
  <p>Here is the redirect to the login url in chrome.  As you can see the # portion of the URL is somehow preserved in the sample app even though its not present in request in the controller and i don't see it in fiddler.</p>
  
  <p><img src="https://i.stack.imgur.com/m1bLT.png" alt="enter image description here"></p>