如果我用MVC3页面太多ViewBag什么?什么极端的问题会在那里,如果我继续大量使用它们。在少言,什么是ViewBag的缺点,什么是替代呢?
解决方案什么是它的备用?
您应该只使用ViewModels,这是推荐的方法。创建强类型的意见。它将使你的code更清洁,易于维护。
什么极端的问题,将在那里?
问题与Viewbags / ViewData的是编译时检查。 ViewBags只是字典,你不会知道,直到左右运行时的任何问题,因此它使你的code容易出错。所以,总是试图去用的ViewModels。
What if i use too many ViewBag in MVC3 page? What extreme problems will be there if i continue use them heavily. In less words, what are the disadvantages of ViewBag and what is the alternate for it?
解决方案what is the alternate for it?
You should only use ViewModels, It's the recommended approach. Create Strongly typed views. It would make your code cleaner and easy to maintain.
What extreme problems will be there?
Issue with Viewbags/ViewData is compile time checking. ViewBags are just dictionaries and you won't be aware about any issues until run time and thus it makes your code error-prone. So always try to go with ViewModels.
更多推荐
为什么不使用ViewBag严重?
发布评论