The previous chapter talked about the controller and returned the string type, but the user interface is often not a simple string to satisfy, so MVC has a view
The responsibility of the view is to provide the user interface to the user,
Below we create a new view
@{ Layout = null;} <! DOCTYPE html>
This view is very simple just to return a text by viewbag
Let's take a look. If you specify a view from the controller
public class Homecontroller:controller { //// GET:/home/public actionresult Index () { Viewbag.mes = "Hello"; Return View ("Sample"); } }
This is a simple controller that returns to the sample's view after the MES amplitude and does not require a suffix
We can see that the Controller base class for MVC contains multiple view overloads
protected internal ViewResult view (IView view); protected internal ViewResult View (object model); protected internal ViewResult View (string viewName); Protected internal Virtual ViewResult view (IView view, object model); protected internal ViewResult View (string viewName, object model); protected internal ViewResult View (string viewName, String mastername); Protected internal virtual ViewResult View (String viewName, String Mastername, object model);
can be accessed according to their actual requirements, in the method above we specified a return view of the sample
If we do not specify how the view controller will match the view, first it will find the same directory home under the index name of the view, if not found will be an error
MVC View Simple Introduction (internal use)