How can I set a variable on a _Layout page?

后端 未结 3 1548
温柔的废话
温柔的废话 2021-02-13 19:01

I have a view and I want to use a layout page. In the layout page I want to have a conditional banner which some of the view will turn on/off. Just wondering how I can do this?<

3条回答
  •  心在旅途
    2021-02-13 19:31

    Having a model for your layout is not a good idea as it will force all views to use that model. However, you could put that type of information into the ViewBag and have the value populated in the constructor of one of your controller bases.

提交回复
热议问题