What is the execution order of an MVC Razor view/layout

后端 未结 4 1975
隐瞒了意图╮
隐瞒了意图╮ 2021-01-03 21:16

I have a razor layout like:

@using (var context = SetUpSomeContext()) {
    
Some content here @RenderBody();
} <
4条回答
  •  天命终不由人
    2021-01-03 22:08

    If you require some logic on all your views, create a ViewModelBase that all your ViewModels inherit from.

    Then in your Controller(Base) you can initialize the ViewModel.SharedContext and other properties.

提交回复
热议问题