Is ViewData the new standard over ViewBag for ASP.Net 5 (core)?

前端 未结 1 591
情歌与酒
情歌与酒 2021-02-03 21:13

I have noticed that in all the examples and tutorials on ASP.Net 5 (core) I have seen from Microsoft and the default Web Application template in VS 2015 use @ViewData[\"XX

相关标签:
1条回答
  • 2021-02-03 21:52

    Both are still valid. There is no specific guidance on the docs.asp.net github project. Although there is this discussion on docs.asp.net issues.

    That links through to a comment from one the product team which says:

    "Since ViewData (Dictionary) look-ups far out-perform ViewBag (dynamic) invocations, the last is probably the best choice."

    So I'd say it purely a style choice based upon the fact that ViewData performs better.

    0 讨论(0)
提交回复
热议问题