Calling another different view from the controller using ASP.NET MVC 4

后端 未结 5 1755
夕颜
夕颜 2020-12-05 03:58

I have a view (Index.cshtml) with a submit button. When the submit button is clicked, it calls an action (Action01) within the controller (TestController.cs) so at the end o

5条回答
  •  臣服心动
    2020-12-05 04:39

    Also, you can just set the ViewName:

    return View("ViewName");
    

    Full controller example:

    public ActionResult SomeAction() {
        if (condition)
        {
            return View("CustomView");
        }else{
            return View();
        }
    }
    

    This works on MVC 5.

提交回复
热议问题