ASP.NET MVC 3 - redirect to another action

前端 未结 5 1301
攒了一身酷
攒了一身酷 2020-12-02 18:20

I want to redirect the Index action of the Home controller to another controller\'s action and nothing else. My code is thus:

    public void Index()
    {
          


        
5条回答
  •  旧巷少年郎
    2020-12-02 18:30

    You have to write this code instead of return View(); :

    return RedirectToAction("ActionName", "ControllerName");
    

提交回复
热议问题