Reputation: 309
I've a couple conceptual questions about the relationship between the Controller Action Method and the View:
I see that the name of the view is in function of Controller's name; the name of the controller class is the same of the namespace of the view (represented by the name of the folder where is the .cshtml file) and the name of the method is the same name of the .cshtml file which is the view. Why it works so? If I miss something in the explanation, How it exactly work?
Is there a way where I can put the .cshtml files (views) outside from the folder which match the name of the Controller's class name?
Is a restriction from MVC that names of .cshtml files match the name of the controllers action methods?
What exactly is the View() method which is returned in the controller action method?
Why the methods of the controller class are called "Controller Action Methods"?
Is a restriction from MVC that the names for the controllers end with "Controller" word?
Thanks to all
Upvotes: 0
Views: 247
Reputation: 2379
I would highly suggest running through a tutorial on MVC, such as this codeproject tutorial.
return View("~/this/is/your/path/ViewName.cshtml");
return View()
attemps to navigate to the return View("MethodName");
void
or string
, but instead ActionResult
will tell your project to do something, such as redirect to another method or return a ViewResult via View()
.Upvotes: 1