I have the following LogOn Action
[HttpPost]
public ActionResult LogOn(LogOnModel user, string returnUrl)
{
if (!String.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Home");
}
}
In which My returnUrl is null..
Can any body tell me .Why my return URL is null
That’s depends how you call the controller action method.
If you have an URL like below
http://www.somedomain.com/LogOn/LogOn?returnUrl=user/userList
In this call, your
returnUrlparameter of anActionMethod(LogOnwill be replaced byquerystringparameterreturnUrl.If you’re using
form authentication, there is an[Authorize]attribute which validated the authentication. If user is NOT authenticated, then it will redirect to theLogInpage with thequerystring parameter returnUrlwhich will have a requested page url in it.At this moment, you will also get
returnUrlvalue in controller’s action method parameter withreturnUrlparamter with value which will haverequested page UrlHope this helps!