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

后端 未结 10 1849

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:22

    I encountered the same problem when I use mvc3, and I found that

    this.ViewBag.ViewBag.PropertyName 
    

    works in your custom control.

提交回复
热议问题