Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Removing empty block controllers for better performance


I am currently looking at this interesting article:

I am a bit of an episerver newbie, so while looking through our Episerver project I came across this block controller:

using System.Web.Mvc;
using BestDigital.Site.Models.Blocks;
using EPiServer.Web.Mvc;

namespace BestDigital.Site.Controllers
    public class AboutUsGridBlockController : BlockController<AboutUsGridBlock>
        public override ActionResult Index(AboutUsGridBlock currentBlock)
            return PartialView(currentBlock);

I this is what is considered an "empty" block controller in the article? Because if I understood it correctly all this block controller is doing is handing over data to the View?

Jul 22, 2020 11:37

Yup. That controller is a good example of one you can get rid of. Doesn't do a lot for performance but everything counts...

Jul 22, 2020 11:46

Thanks very much Daniel.

In theory, in such a case, all I would need to do is delete this Block Controller provided that in my View as the @model there is a reference to the actual model of this block correct?

Jul 22, 2020 11:56

Exactly. A block controller like this is rarely needed.

By registering the model and partial view combination from a ViewTemplateModelRegistrator, you can skip the controller completely. I once posted this sample.

Jul 22, 2020 12:00

Thanks so much Stefan, just so I understand correctly (I may have misundertood) but does this registrator go in the model for this block?

Jul 22, 2020 12:05
Stefan Holm Olsen - Jul 22, 2020 12:15
No, the registration is a class you create that inherits from an interface (see the documentation I link to in the sample).
You can place such a class in each Feature folder, if you structure your project like that.

While it's certainly an improvement, based on the numbers in the blogpost, I think there are more low hanging fruits for you to try out first. I'd suggest to try with load test + profiler to see bottlenecks in your website and work on those.

Jul 22, 2020 12:32

Yeah, it's a performance improvement but it's very minor. If you have performance issues on your site it's 90% because of slow integrations towards other systems based on my experience. is a good tool to find out which calls are made and how slow they are.

Jul 22, 2020 13:49

Thank you all for the feedback. The suggested ViewTemplateModelRegistrator worked really nicely. 

Jul 28, 2020 8:44
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.