-
Notifications
You must be signed in to change notification settings - Fork 25.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
viewbag or viewdata. #803
Comments
@Eilon Is there guidance from the product team on when to use ViewBag vs ViewData or is the choice purely stylistic? |
Aha, I found the issue where I was looking for , but it is only about performance and not preferred style |
Also the templates changed from viewbag to viewdata in beta7 or beta8 |
@Anderman I think the conclusion in that quote is inadvertently reversed. It says:
But I'm quite certain it meant to say:
However, the product team has no particular guidance on this. Both approaches have their pros and cons. Which one looks better is clearly a matter of taste. Neither has any particular advantage over the other when it comes to readability or technical merits. The dictionary lookup is most likely a bit faster, but whether that is of any significance depends on the app, so I would be weary of using that as an initial bit of guidance. What I would recommend above both of these options is to use a strongly-typed view model, which has numerous technical, performance, readability, refactoring, and other advantages. It does has one disadvantage in that it's "harder to do" in terms of setup and maintenance. When I write apps I often use a mix of both. |
Closing this issue. |
@shirhatti @rachelappel can we find a place to add Eilon's awesome info? @rachelappel can you fit that in your model binding doc? |
I though viewdata was the replacement for viewbag because it was faster. But i can't find it anymore on github.
In some samples viewbag is stil used. Should this be replace by viewdata?
see http://docs.asp.net/projects/mvc/en/latest/views/view-components.html#add-invokeasync-to-the-priority-view-component
The text was updated successfully, but these errors were encountered: