Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
475 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...