Page Redirection in ASP.NET MVC:-
Using this we can redirect from one page to another using controller method,ASP.NET MVC provide three different types of ActionResult for Page Redirection.
1) Redirect() :-
Using this we can redirect from one page to another using controller method,ASP.NET MVC provide three different types of ActionResult for Page Redirection.
1) Redirect() :-
We can pass the complete URL under redirect(), we will use the web URL of the current application or cross-application using Redirect().
public ActionResult Methodname()
{
return Redirect("url");
}
2) RedirectToAction():- We can pass Actionname and Controllername under RedirectToAction(). It will work using Single Parameters and Multiple Parameters both.
public ActionResult Methodname()
{
// return RedirectToAction("Methodname");
return RedirectToAction("Methodname","Controllername");
}
3) RedirectToRoute() :- We can pass Actionname and Controllername using Routename by routeconfig.cs under RedirectToRoute(). It will work using route name ;
public ActionResult Methodname()
{
return RedirectToRoute("Routername");
}

public ActionResult Methodname()
{
return Redirect("url");
}
2) RedirectToAction():- We can pass Actionname and Controllername under RedirectToAction(). It will work using Single Parameters and Multiple Parameters both.
public ActionResult Methodname()
{
// return RedirectToAction("Methodname");
return RedirectToAction("Methodname","Controllername");
}
3) RedirectToRoute() :- We can pass Actionname and Controllername using Routename by routeconfig.cs under RedirectToRoute(). It will work using route name ;
public ActionResult Methodname()
{
return RedirectToRoute("Routername");
}

Post a Comment
If you have any doubt in programming or join online classes then you can contact us by comment .