Why can't _ViewStart.cshtml access the ViewBag object?

前端 未结 6 1785
孤街浪徒
孤街浪徒 2020-12-30 19:12

I have the default _ViewStart.cshtml in my /Views folder. I\'d like to be able to access my ViewBag object so I can set the default title for all my views.

However,

6条回答
  •  梦毁少年i
    2020-12-30 20:03

    Its not 100% clean but see a workaround using PageData or a bit of enumeration at:

    How do I set ViewBag properties on _ViewStart.cshtml?

提交回复
热议问题