Controller.ViewData Controller.ViewData Controller.ViewData Property

Definition

Gets or sets ViewDataDictionary used by ViewResult and ViewBag.

[Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary]
public Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData { get; set; }
member this.ViewData : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary with get, set
Public Property ViewData As ViewDataDictionary

Property Value

Remarks

By default, this property is initialized when IControllerActivator activates controllers.

This property can be accessed after the controller has been activated, for example, in a controller action or by overriding OnActionExecuting(ActionExecutingContext).

This property can be also accessed from within a unit test where it is initialized with EmptyModelMetadataProvider.

Applies to