I want to use a redirection to the requested URL a user wanted to access after the login but somehow the returnUrl is always null. (I did research on that topic for half an hour and didn't find a solution working for me.)
I debugged the Login view of my app and I'm trying to get the ReturnUrl with
new { ReturnUrl = Request.QueryString["ReturnUrl"] }
inside of my @using() tag. I saw that the QueryString is an empty collection and I even tried to use it without QueryString or just with ViewBag.ReturnUrl but neither the one nor the other worked for me.
The controller has the right parameters and it do redirect via RedirectToLocal(returnUrl) but that doesn't matter if the returnUrl is null.
Request.QueryString["ReturnUrl"]is empty then it seems to follow that there is noReturnUrlvalue on the query string.Request.QueryString["ReturnUrl"]inside your view page will be empty. its available in controllerFormsAuthenticationand all other pages are secured with Login, then the page requested will be automatically appended toReturnUrlif browse for a page other than Login