What is the life cycle of an HTTP request in MVC standards?

Asked

Viewed 206 times

2

I’ve been developing in ASP.NET MVC5 for 1 year and 2 months, and to this day I can’t quite understand who calls who. Researching further, I found that answer that says(in free translation):

Lifecycle of an HTTP request:

User makes HTTP request;

The controller intercepts;

The controller calls the appropriate service;

The service calls the appropriate DAO which returns some persistent data (for example);

The service handles the data and returns to the controller;

The controller stores the data in the model and calls the view;

View populates with model data and returns HTTP request.

What would that be service ? Currently I call static classes that do the processing, save and recover data from the database, this would be the same thing as these services?

1 answer

0


Service is one of the 3 application layers

The question you posted as a reference to your question, calls "service" the intermediate layer of the application. This intermediate layer is described within a 3-tier architecture (data, services, presentation), where the service layer would have the code that accesses the data layer, applies business rules, and returns to the presentation layer to display to the user.

The answer puts the MVC inside the presentation layer. The call made to the controller, passes to the service layer that calls the data layer (DAO), makes a treatment with this data and applies business rules, and returns to continue and be directed to the View, where it would be formatted (HTML) for presentation to the user.

This layer separation is a logical separation within the system, but it is possible to have an implementation where the service layer had to be accessed through a call to an API that resides on another machine and after the return send the received data to the View.

Browser other questions tagged

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