ViewComponent Class¶
A base class for view components.
- Namespace
Microsoft.AspNetCore.Mvc
- Assemblies
- Microsoft.AspNetCore.Mvc.ViewFeatures
Inheritance Hierarchy¶
System.Object
Microsoft.AspNetCore.Mvc.ViewComponent
Methods¶
-
Content
(System.String)¶ Returns a result which will render HTML encoded text.
Arguments: content (System.String) – The content, will be HTML encoded before output. Return type: Microsoft.AspNetCore.Mvc.ViewComponents.ContentViewComponentResult Returns: A Microsoft.AspNetCore.Mvc.ViewComponents.ContentViewComponentResult
.public ContentViewComponentResult Content(string content)
-
View
()¶ Returns a result which will render the partial view with name <code>”Default”</code>.
Return type: Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult Returns: A Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult
.public ViewViewComponentResult View()
-
View
(System.String) Returns a result which will render the partial view with name <em>viewName</em>.
Arguments: viewName (System.String) – The name of the partial view to render. Return type: Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult Returns: A Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult
.public ViewViewComponentResult View(string viewName)
-
View<TModel>
(System.String, TModel)¶ Returns a result which will render the partial view with name <em>viewName</em>.
Arguments: - viewName (System.String) – The name of the partial view to render.
- model (TModel) – The model object for the view.
Return type: Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult
Returns: A
Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult
.public ViewViewComponentResult View<TModel>(string viewName, TModel model)
-
View<TModel>
(TModel) Returns a result which will render the partial view with name <code>”Default”</code>.
Arguments: model (TModel) – The model object for the view. Return type: Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult Returns: A Microsoft.AspNetCore.Mvc.ViewComponents.ViewViewComponentResult
.public ViewViewComponentResult View<TModel>(TModel model)
-
Properties¶
-
Microsoft.AspNetCore.Mvc.ViewComponent.
HttpContext
¶ Gets the
Microsoft.AspNetCore.Http.HttpContext
.Return type: Microsoft.AspNetCore.Http.HttpContext public HttpContext HttpContext { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
ModelState
¶ Gets the
Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary
.Return type: Microsoft.AspNetCore.Mvc.ModelBinding.ModelStateDictionary public ModelStateDictionary ModelState { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
Request
¶ Gets the
Microsoft.AspNetCore.Http.HttpRequest
.Return type: Microsoft.AspNetCore.Http.HttpRequest public HttpRequest Request { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
RouteData
¶ Gets the
Microsoft.AspNetCore.Mvc.ViewComponent.RouteData
for the current request.Return type: Microsoft.AspNetCore.Routing.RouteData public RouteData RouteData { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
Url
¶ Gets or sets the
Microsoft.AspNetCore.Mvc.IUrlHelper
.Return type: Microsoft.AspNetCore.Mvc.IUrlHelper public IUrlHelper Url { get; set; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
User
¶ Gets the
System.Security.Principal.IPrincipal
for the current user.Return type: System.Security.Principal.IPrincipal public IPrincipal User { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
ViewBag
¶ Gets the view bag.
Return type: System.Object public dynamic ViewBag { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
ViewComponentContext
¶ Return type: Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext public ViewComponentContext ViewComponentContext { get; set; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
ViewContext
¶ Gets the
Microsoft.AspNetCore.Mvc.ViewComponent.ViewContext
.Return type: Microsoft.AspNetCore.Mvc.Rendering.ViewContext public ViewContext ViewContext { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
ViewData
¶ Gets the
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary
.Return type: Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary public ViewDataDictionary ViewData { get; }
-
Microsoft.AspNetCore.Mvc.ViewComponent.
ViewEngine
¶ Gets or sets the
Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine
.Return type: Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine public ICompositeViewEngine ViewEngine { get; set; }
-