Dela via


Controller.ViewData Property

Definition

Gets or sets ViewDataDictionary used by ViewResult and ViewBag.

public:
 property Microsoft::AspNetCore::Mvc::ViewFeatures::ViewDataDictionary ^ ViewData { Microsoft::AspNetCore::Mvc::ViewFeatures::ViewDataDictionary ^ get(); void set(Microsoft::AspNetCore::Mvc::ViewFeatures::ViewDataDictionary ^ value); };
[Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary]
public Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary ViewData { get; set; }
[<Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary>]
member this.ViewData : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary with get, set
Public Property ViewData As ViewDataDictionary

Property Value

Attributes

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