For example i have web site with heavy layout(masterpage). And for layout render we need to get some stuff from database and maybe do some calculations.
But where i must put this code?
The Haacked blogged about the Html.RenderAction helper (also refereed as child actions) which seem like a perfect fit for your scenario. It allows you to embed partials/widgets in your site that go through a separate Controller/Model/View lifecycle than the main one. Very useful for incorporating common widgets in your Layout without the need of having your main controller worry about this transverse logic.
您应该将该逻辑放在子操作中并在布局中调用它们。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.