The Mvc is composed of 3 layers Model View and Controller, in Asp . net mvc we have the following flow:
the web browser calls an action such as your/Controller/action domain or to better exemplify localhost/home/index as shown in the code below:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
You can notice that the first thing it calls is the controller/Action that in turn works as a manager, doing a step by step until you get to the view, in the code below we have an implementation where the controller has to fetch data, so in this case it will have to access the model.
public ActionResult Index()
{
var person = new PersonRepositoty();
var model = person.PersonRep.Get();
return View(model);
}
Which then goes to the view, which is in View/Home/index.
Soon to my way of seeing the controller is a manager who can consult a model to fetch data and finally pass to a view that will present in a user’s screen.
Note: Every Actionresult has a view.
You’re sure this is MVC. It’s not the MVC I know. The article you quoted says otherwise. You’re using Webforms. Although it’s possible model it as MVC (it takes work, it doesn’t pay, I don’t know anyone who did it) it’s not him who is used for MVC.
– Maniero
I gave this example because I think the question of @Caique C. was what the conversation code between the layers looks like, see this excerpt from the question "Could someone give an example of C# code without using the MVC framework?".
– Gustavuu
I get it, the title and internal questions are discrepant.
– Maniero