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

后端 未结 10 1840

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

    You can do this trick in your partial view to override the title in your _Layout.cshtml:

    @{
        ViewBag.Title = "About Us From The Partial View";
    }
    
    ......
    
    
    

提交回复
热议问题