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

后端 未结 8 1388
无人共我
无人共我 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:40

    In a comment TehOne said:

    I know this is a bit old, but for future reference, I solved this by using ViewContext.Controller.ViewBag.Property. Of course this means that the ViewBag property you are trying to access was set in the controller, but I think that is a common enough case.

    Which is what worked for me.

提交回复
热议问题