c# - RedirectToLocal not found

ID : 274302

viewed : 36

Tags : c#asp.netasp.net-mvcrazorc#





Top 2 Answer for c# - RedirectToLocal not found

vote vote

100

RedirectToLocal is not part of the framework. It is added in some of the MVC templates in the Account Controller:

This is taken from the MVC5 template AccountController:

private ActionResult RedirectToLocal(string returnUrl) {     if (Url.IsLocalUrl(returnUrl))     {         return Redirect(returnUrl);     }     else     {         return RedirectToAction("Index", "Home");     } } 

If you want this method in all of your controllers, then you could easily add it as a protected method in a base controller, and have all of your controllers inherit from that base:

public abstract class BaseController : Controller {     protected ActionResult RedirectToLocal(string returnUrl)     {         if (Url.IsLocalUrl(returnUrl))         {             return Redirect(returnUrl);         }         else         {             return RedirectToAction("Index", "Home");         }     } }  public class HomeController : BaseController {     // ... } 
vote vote

81

Top 3 video Explaining c# - RedirectToLocal not found







Related QUESTION?