Vulnerability in EPiServer.Forms
I am currently looking at this interesting article: https://swapcode.wordpress.com/2018/05/16/episerver-block-performance-with-controller-vs-without-controller-vs-irendertemplate/
I am a bit of an episerver newbie, so while looking through our Episerver project I came across this block controller:
public class AboutUsGridBlockController : BlockController<AboutUsGridBlock>
public override ActionResult Index(AboutUsGridBlock 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?
Yup. That controller is a good example of one you can get rid of. Doesn't do a lot for performance but everything counts...
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?
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.
Thanks so much Stefan, just so I understand correctly (I may have misundertood) but does this registrator go in the model for this block?
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.
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. Prefix.io is a good tool to find out which calls are made and how slow they are.
Thank you all for the feedback. The suggested ViewTemplateModelRegistrator worked really nicely.