top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

When I type return View() how does it know which view to return?

0 votes
309 views
When I type return View() how does it know which view to return?
posted Sep 6, 2016 by Sathyasree

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

-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”);
}
answer Sep 8, 2016 by Shivaranjini
...