Return view from action method in ASP.NET MVC
How to return a view from controller action method?
To return a view from the controller action method, we can use View() method by passing respective parameters.
ACTION METHOD CODE
public ViewResult OutputView()
Views: 66826 | Post Order: 61
- return View() – returns the view corresponding to the action method
- return View(“ViewName”) – returns the view name specified in the current view folder (view extension name “.cshtml” is not required.
- return View("~/Views/Account/Register.cshtml") – returns the Register view under /Views/Account folder (view extension name “.cshtml” is required as we are passing the complete path name of the view that exists in another folder).