Two ways to return the ASP.NET MVC method View

1. The parameter is a string type

For example, we enter in the address bar http: // localhost: 56431 / Test / Index, the Index method looks at TestController class and perform the following figure

When we return to view parameters of type String time

Views view looks at Test under aaa.cshtml and return, if not the file, looks for Shared folder to see if there is, if there is no, it will error.

2. The string type and model type

The first parameter "aaa" will go to View - aaa.cshtml under Test, and brought it into the second model parameters

Note: When only one model parameters or no parameters, returns the method name and the same view of the page. E.g:

public ActionResult KK(){

  return View();

}

Find KK.cshtml file will go to View --- Test

Guess you like

Origin www.cnblogs.com/1016391912pm/p/12110055.html