Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

Class ViewExtensions

Extensions to Microsoft.AspNetCore.Mvc.ViewEngines.IView and Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper regarding rendering.

Inheritance
System.Object
ViewExtensions
Namespace: EPiServer.Web.Mvc
Assembly: EPiServer.Cms.AspNetCore.Mvc.dll
Version: 12.0.3
Syntax
public static class ViewExtensions : Object

Methods

RenderAsync<T>(IView, ViewEngineResult, ViewContext, TextWriter, T)

Renders a view on the stream

Declaration
public static Task RenderAsync<T>(this IView view, ViewEngineResult viewEngineResult, ViewContext context, TextWriter writer, T data)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.ViewEngines.IView view
Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult viewEngineResult

The result from a view search

Microsoft.AspNetCore.Mvc.Rendering.ViewContext context

The context of the current view

System.IO.TextWriter writer

The writer to write to

T data

Data to add to the context

Returns
Type Description
System.Threading.Tasks.Task
Type Parameters
Name Description
T

RenderPartial<T>(HtmlHelper, T)

Renders a partial view of the specified model.

Declaration
public static void RenderPartial<T>(this HtmlHelper helper, T model)
Parameters
Type Name Description
Microsoft.AspNetCore.Mvc.ViewFeatures.HtmlHelper helper

The html helper that this method extends.

T model

The model to render.

Type Parameters
Name Description
T

The type of model to render.

Remarks

This method will try to find a partial view that matches the name of the type T and use that to render the specified model.