What's the same page lifecycle behavior in asp.net core mvc?

Xie Steven 831 Reputation points
2021-07-29T03:50:54+00:00

Hi,

I'm porting the old asp.net webform project to asp.net core mvc. The webform page has OnInit method, Load event, Error event. In these event handlers, there're some code logic in it.

I'm new beginner to asp.net core. I do not know to where to place these code.

Please tell me which phase of the asp.net core mvc life cycle that these events correspond to.

Thanks

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,553 questions
{count} votes

Accepted answer
  1. Bruce (SqlWork.com) 65,131 Reputation points
    2021-07-29T14:48:55.39+00:00

    Webforms built a control tree and fired events, for example oninint after the tree built, on load after tree built and postback data applied, etc. finally onrender, when the tree was converted to html.

    Mvc is a different model. An action is called to build a view model. Then a view is called to render the model. The view is a template engine, so there are no events. The post data is passed to the action rather than being applied to a control tree.

    Mvc has request pipeline with event filters. Pre action, post action, etc.

    The action controller can catch errors via an exception handler, otherwise an error action is called. You can also override the default error action.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.