You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Started this as a way to ensure we're aware of a behavior change between Mvc 5 and Mvc 6. In Mvc 5, initializing a helper (HtmlHelper<T>) would cause it to shallow copy the passed in ViewDataDictionary. This meant the Html.ViewData instance is different from the ViewData instance on the WebViewPage. Consequently, mutating Html.ViewData would leave the ViewData unaffected - it had the same behavior as a partial. This resulted in behavior like this:
I bet there was some super smart reason for how it was in MVC 1 - 5... not...
I can see arguments for having it either way, but I have to admit that whenever I hear "shallow copy" I cringe a little bit because it often falls into the category of "why bother." It's sort of a half-a-cat scenario (not always, but I think in this case it is).
I think I'm supportive of going with the new behavior and seeing how it plays out...
Started this as a way to ensure we're aware of a behavior change between Mvc 5 and Mvc 6. In Mvc 5, initializing a helper (
HtmlHelper<T>
) would cause it to shallow copy the passed in ViewDataDictionary. This meant theHtml.ViewData
instance is different from theViewData
instance on theWebViewPage
. Consequently, mutatingHtml.ViewData
would leave the ViewData unaffected - it had the same behavior as a partial. This resulted in behavior like this:In Mvc 6, helpers do not create a copy of the ViewData and reference it directly from the passed in ViewContext. This produces the result
IMO, the behavior in Mvc 6 seems like the correct behavior, but I may be missing some scenarios that are affected by this change.
cc @Eilon \ @dougbu
The text was updated successfully, but these errors were encountered: