What is the build flow of the . NET framework?

Asked

Viewed 82 times

2

I’m starting my walk on .NET. I’m programming in ASP.net but I can’t understand how an Asp.net project turns into html + javascript. I suppose there’s a compilation process behind it.

Apart from this I would like to know at Model Control View what files are responsible for each of these tasks? In my case the view will be aspx, the control and the model will be Vb.net. I’ll be right?

You can share your knowledge?

Thank you

1 answer

0

MVC: Model, View, Controller.

Model: Application logic layer is where you put your application’s business rule (using C# or Vb.net for example) is where you manage data, logic and application rules.

View: Responsible for displaying your page, it needs to be compiled in real time, after which it generates an HTML. The coding gives through the programming language you will be able to popular the HTML with the data brought from the Controller.

Controller: This is where the requests are processed, captures the received data in order to pass it to the Model that will respond with data (if necessary), once received the data, the Controller must respond is by returning raw data through JSON for example or by returning a View with data.

How does the cycle work in practice? (Example in ASP.NET MVC C#)

  • The user accesses the page www.google.com and type Stackoverflow;

Controller will receive a Model with the data entered in the form of the Google page.

public ActionResult Index(SearchModel search) //Passo 1 - A pesquisa se encontra dentro do Model enviado para o Controller
{
    search.SearchResponse = search.Search(); //Passo 2 - Método Search() retorna o objeto SearchResponse para dentro da própria classe SearchModel
    return View(search); //Passo 3 - O model é retornado para a camada de visualização (View)
}  

Model when called through the Controller processes logic and responds with what was requested.

public class SearchModel
{
    public String SearchInput {get;set;}
    public SearchResponse SearchResponse {get;set;}

    public SearchResponse Search()
    {
        //Lógica do método Search
    }
}

3°A View processes the data brought from Controller which were processed in Model.

<body>
    @foreach(SearchResult result in Model.SearchResponse.SearchResult)
    {
        <p>@result.Description</p> 
    }

</body>

4° User browser receives the following:

<body>
    <p>Stack Overflow é um website de capital fechado, o site principal da Rede Stack Exchange. Foi criado em 2008 por Jeff Atwood e Joel Spolsky como uma ...</p>

    <p>Over the weekend, there was an attack on Stack Overflow. We have confirmed that some level of production access was gained on May...</p>  
</body>

These are just practical examples of answers, the HTML is returned in a complete way (with <html>,<head> and everything else that was set in its Layout)

On this page from Microsoft also gives to have a basic notion of how things work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.