Use @ViewContext.Controller.ViewData
to access the ViewData
current controller. Assuming you want to get this out of the view you are currently in. This will help to see a precedent.
ViewData
is part of WebViewPage
and is not something accessible from HttpContextBase
.
After reading your comment on another answer, you can use HttpContext.Current.Items
to create items that are available only for the current request.
source share