首页 新闻 会员 周边

asp.net mvc core 中的ViewDataDictionary怎么使用?

0
悬赏园豆:20 [已解决问题] 解决于 2018-05-29 15:19

在.net mvc core中不能像在.net mvc中直接使用var data = new ViewDataDictionary(),请问在core中怎么使用ViewDataDictionary?

逗多多的主页 逗多多 | 初学一级 | 园豆:89
提问于:2018-05-29 11:12
< >
分享
最佳答案
0

在 asp.net core 中需要给 ViewDataDictionary 构造函数传值

public IActionResult Index()
{
    var data = new ViewDataDictionary(ViewData);
    data["Message"] = "Your application description page.";
    return Content(data["Message"].ToString());
}
收获园豆:20
dudu | 高人七级 |园豆:30994 | 2018-05-29 14:23

正解

逗多多 | 园豆:89 (初学一级) | 2018-05-29 15:19
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册