When is it appropriate to store data in HttpContext.Current.Items[...]
vs storing data in ViewData[...]
?
I'm trying to figure out the best practices for storing data in this collection and I'm not sure if it's safe to store user-specific data in HttpContext.Current.Items
.
One use-case is passing down user credits from a base controller's OnActionExecuting(...)
to be used in Controller
calculations and for display in Views
; I know I should be using ViewData
for this, but I've had some inconsistent results with nested partial views.
Would it be correct to say that HttpContext.Current.Items[...]
is to Controllers
like ViewData[...]
is to Views?