将字典放在Viewbag中

Mih*_*abo 0 model-view-controller asp.net-mvc-3

我正在尝试在我的视图中访问字典.但是以下语法:

@{
    var indexList = Viewbag.IndexList as Dictionary<int,long>;
}
Run Code Online (Sandbox Code Playgroud)

不起作用:The name 'Viewbag' does not exist in the current context

PS:尝试在Viewbag之前放置'@',仍然无法正常工作.

有人可以帮忙吗?提前致谢

Pau*_*aul 5

是不是ViewBag?

var indexList = ViewBag.IndexList as Dictionary<int,long>;
Run Code Online (Sandbox Code Playgroud)

  • 区分大小写.资本化很重要 - 它的区别在于:帮助你的叔叔杰克脱离马匹,并且:帮助你的叔叔杰克脱离马......非常重要! (9认同)