Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Controllerless EPiServer how to?

Vote:
 

Hi,

I've tried to follow this code to implement Controllerless EPiServer.

https://swapcode.wordpress.com/2018/05/16/episerver-block-performance-with-controller-vs-without-controller-vs-irendertemplate/

In short:

public abstract class ViewRenderTemplate<T> : IView, IRenderTemplate<T> where T : class, IContentData ...

When implementing this abstraction:

[TemplateDescriptor(Default = true, AvailableWithoutTag = false)]
public class StartPageViewRender : ViewRenderTemplate<StartPage>
{

I have tried a lot of options for the "TemplateDescriptor" attribute, but nothing seems to work.

With Tags, without Tags, with TemplateTypeCategory, with typeof(StartPage) as model type etc etc.

Have I missed anything?

#229583
Oct 19, 2020 5:32
Vote:
 

There's no reason to do this for pages. The "issue" is block controllers, which are only needed if you need to construct a view model. I.e. if your view for the block only needs the data from the BlockData instance, then there's no need for the block controller. Sometimes you need to controll which view should be used, e.g. different view per display tag, that can be achieved with a block controller as well, but then there's a better way: IViewTemplateModelRegistrator. See How To Make A Block Use Multiple Views ? A Partial View Controller Explained - Jon D Jones (jondjones.com).

#229599
Oct 19, 2020 15:59
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.