How to simulate Server.Transfer in ASP.NET MVC?

后端 未结 14 1555
死守一世寂寞
死守一世寂寞 2020-11-22 12:00

In ASP.NET MVC you can return a redirect ActionResult quite easily :

 return RedirectToAction(\"Index\");

 or

 return RedirectToRoute(new { controller = \"         


        
14条回答
  •  青春惊慌失措
    2020-11-22 12:28

    Couldn't you just create an instance of the controller you would like to redirect to, invoke the action method you want, then return the result of that? Something like:

     HomeController controller = new HomeController();
     return controller.Index();
    

提交回复
热议问题