Can't access ViewBag in a partial view in ASP.NET MVC3

后端 未结 8 1408
无人共我
无人共我 2020-12-08 06:32

I have a controller calling a view. In the view there is a PartialView called be @Html.Partial(\"ViewName\", model). This works fine.

But i

8条回答
  •  春和景丽
    2020-12-08 06:47

    I was having this same problem with a very basic page:

    @Html.Partial("_AppIntro")
    
    
    

    And the partial view contained only text with some references to ViewBag to fetch some dynamic values passed from the controller. It turned out that the name of the partial view mattered. Removing the partial page and recreating it with Add -> View -> MVC 5 View but naming the page _AppIntro.cshtml fixed it.

提交回复
热议问题