Modifying MVC 3 ViewBag in a partial view does not persist to the _Layout.cshtml

后端 未结 10 1836

I am using MVC 3 with the Razor view engine. I want to set some values in the ViewBag inside a Partial View and want retrieve those values in my _Layout.cshtml. For exampl

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-08 14:12

    The partial view gets its own ViewBag.

    You can get the page's ViewBag from ((WebViewPage) WebPageContext.Current.Page).ViewBag

提交回复
热议问题