When I type return View() how does it know which view to return?
When I type return View() how does it know which view to return?
-The view that will be returned has the same name as the method in the controller.
-For example if you have a method in the Employee controller with the following implementation:
public ActionResult GetEmployees()
{
Return view();
}
-Then we creat a view named GetEmployees in the Employee folder inside of Views. This is not mandatory, however, and we can return give a alternate name to the views passing the name of the view as a string as below:
public ActionResult GetEmployees ()
{
Return view(“EmployeeDetails”);
}