ِِHow to Access the viewbag in the _viewstart.chtml in mvc 5?

ِِHow to Access the viewbag in the _viewstart.chtml in mvc 5?

我需要根据 _viewstart.chtml 中的用户更改布局。我已经看到问题 Why can't _ViewStart.cshtml access the ViewBag object? 中的答案并且答案建议使用 ViewContext.ViewBag 但在 mvc 5 中我有错误

An object reference is required for the nonstatic field, method, or property 

那么我如何在 _viewstart.chtml 中使用 viewbag 或 ViewContext。

尽管 _viewstart 代码中存在错误,但代码将编译并且运行时没有错误