Skip to content

Instantly share code, notes, and snippets.

@jmahc
Last active February 4, 2016 18:26
Show Gist options
  • Save jmahc/b67cf6ed708252dbeaa1 to your computer and use it in GitHub Desktop.
Save jmahc/b67cf6ed708252dbeaa1 to your computer and use it in GitHub Desktop.
Redirect a user to the page they were previously on after they login (.NET, C#)
private ActionResult RedirectToLocal(string returnUrl)
{
string hostUrl = Request.Url.Scheme + "://" + Request.UrlReferrer.Authority;
if (Url.IsLocalUrl(returnUrl))
{
return Redirect(hostUrl + returnUrl);
}
return RedirectToAction("Index", "Home");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment