Controller.ViewData 属性

定义

获取或设置 ViewDataDictionaryViewResultViewBag使用的 。

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

属性值

属性

注解

默认情况下,此属性在激活控制器时 IControllerActivator 初始化。

可以在激活控制器后访问此属性,例如,在控制器操作中或通过重写 OnActionExecuting(ActionExecutingContext)来访问 。

也可以从单元测试中访问此属性,其中它使用 EmptyModelMetadataProvider初始化。

适用于