Try our conversational search powered by Generative AI!

Class PartialContentController<TContentData>

Provides the base implementation for for partial content controllers.

Inheritance
System.Object
PartialContentController<TContentData>
Implements
IRenderTemplate<TContentData>
Namespace: EPiServer.Web.Mvc
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
[AuthorizeContent]
[VisitorGroupImpersonation]
public abstract class PartialContentController<TContentData> : ActionControllerBase, IRenderTemplate<TContentData>, IRenderTemplate where TContentData : IContentData
Type Parameters
Name Description
TContentData

The type of the content data.

Examples
  The following code example demonstrates two simple block controllers.
/// <summary>
/// Simple controller for a block. The base class will delegate the block to a view with the same name as the block type (MyBlock).
/// </summary>
public class EmptyBlockControllerSample : BlockController<MyBlock>
{
}

/// <summary>
/// Controller for a block, which handles it's index action.
/// </summary>
public class BlockControllerSample : BlockController<MyBlock>
{
public override ActionResult Index(MyBlock blockData)
{
return PartialView("MyBlock", blockData);
}
}

/// <summary>
/// Simple block
/// </summary>
[ContentType]
public class MyBlock : BlockData
{
public virtual string MyString { get; set; }
}

public class PageControllerSample : PageController<MyPage>
{
public ActionResult Index(MyPage blockData)
{
return View(blockData);
}
}

[ContentType]
public class MyPage : PageData
{
public virtual MyBlock TheBlock { get; set; }
}

Constructors

PartialContentController()

Declaration
protected PartialContentController()

Methods

Index(TContentData)

Default action, which tries to find a partial view with the same name as the content type.

Declaration
public virtual ActionResult Index(TContentData currentContent)
Parameters
Type Name Description
TContentData currentContent

The current content instance.

Returns
Type Description
System.Web.Mvc.ActionResult

Content from the view

Implements

Extension Methods