Reputation: 47
What is the difference between passing and not passing a view name to the View()
method in an Action
?
public ActionResult Index()
{
return View();
}
VS
public ActionResult Index()
{
return View("Index");
}
What does view()
return in the case of receiving no argument?
Upvotes: 0
Views: 43
Reputation: 3244
If you do not pass the name of the view it would pass the name of the action. In your case when you write return View();
it would be like writing return View("Index");
This is helpful in case your action name changes. Pass the view name only when you are using a shared view in multiple actions. For other cases leave it empty.
Upvotes: 1