ContentViewComponentResult Class

Summary

An [Microsoft.AspNet.Mvc.IViewComponentResult](Microsoft.AspNet.Mvc.IViewComponentResult.yml) which writes text when executed.

Syntax

public class ContentViewComponentResult : IViewComponentResult

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.ContentViewComponentResult

Constructors

ContentViewComponentResult(Microsoft.AspNet.Mvc.Rendering.HtmlString)

Initializes a new [Microsoft.AspNet.Mvc.ContentViewComponentResult](Microsoft.AspNet.Mvc.ContentViewComponentResult.yml).

Arguments:
public ContentViewComponentResult(HtmlString encodedContent)
ContentViewComponentResult(System.String)

Initializes a new [Microsoft.AspNet.Mvc.ContentViewComponentResult](Microsoft.AspNet.Mvc.ContentViewComponentResult.yml).

Arguments:
  • content (System.String) – Content to write. The content be HTML encoded when output.
public ContentViewComponentResult(string content)

Properties

Content()

Gets the content.

Return type:System.String
public string Content { get; }
EncodedContent()

Gets the encoded content.

Return type:Microsoft.AspNet.Mvc.Rendering.HtmlString
public HtmlString EncodedContent { get; }

Methods

Execute(Microsoft.AspNet.Mvc.ViewComponentContext)

Writes the [Microsoft.AspNet.Mvc.ContentViewComponentResult.EncodedContent](Microsoft.AspNet.Mvc.ContentViewComponentResult.yml).

Arguments:
public void Execute(ViewComponentContext context)
ExecuteAsync(Microsoft.AspNet.Mvc.ViewComponentContext)

Writes the [Microsoft.AspNet.Mvc.ContentViewComponentResult.EncodedContent](Microsoft.AspNet.Mvc.ContentViewComponentResult.yml).

Arguments:
Return type:

System.Threading.Tasks.Task

Returns:

A completed [System.Threading.Tasks.Task]().

public Task ExecuteAsync(ViewComponentContext context)