1,在control的action方法中,返回view(),例如:
public ActionResult Create()
{
return View();
}
2,如何找到对应的view?
When this method is called(即 View();方法) with no arguments, the framework infers
that the name of the view to render should be the same as the name of the action
(Create). Later in the MVC pipeline, the framework’s ControllerActionInvoker class
executes the ViewResult and tells it to render the view. At this point, the framework
asks the ViewEngineCollection to locate the appropriate view for rendering.
上面的意思:当执行action方法时,如果return view();没有参数的传入,那么框架就会认为,视图的名称是和action名称一样,
随后,在mvc的管道中,按照如下顺序继续调用框架的类:ControllerActionInvoker ——> ViewEngineCollection,通过ViewEngineCollection类,
定位到相应的view并显示。