Try our conversational search powered by Generative AI!

Block is null in BlockController (Epi 9)



This is our defined block type:

namespace Project.EPiServer.Blocks
    [ContentType(DisplayName = "Rad", GUID = "5090aae4-c0e6-43fd-8bcd-f2507d01972a")]
    public class RowBlock : BlockData
        [Display(Name = "Promo elements", Order = 10)]
        [AllowedTypes(AllowedTypes = new Type[] { typeof(PromoBlock) })]
        public virtual ContentArea Blocks { get; set; }

And this is our block controller:

namespace Project.Web.Controllers
    public class RowBlockController : BlockController
        public override ActionResult Index(RowBlock block)
            return PartialView("...");

The problem is that the block parameter to the Index method is null

Everything works fine when I have a view named "RowBlock" (i.e. without a controller), but when we introduce a controller the block is null. Any suggestions to why this might be?

Thank you.

Mar 16, 2016 10:26
Mar 16, 2016 10:28


I think the problem is the name of the parameter (block). If I remember correctly it has to be called either currentContent or currentBlock. That is because the model binding is looking for a parameter called that to bind the model to.


Per Gunsarfs

Mar 16, 2016 10:56

You are completely correct, Per! Thank you very much for the response.

Mar 16, 2016 16:42

Ha ha, had the same issue with pages, this is the list of working parameter names:

Mar 31, 2016 16:23
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.