Last active
February 4, 2016 18:26
-
-
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#)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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