Block is null in BlockController (Epi 9)

Vote:
 

Hi.

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.

#146325
Mar 16, 2016 10:26
Vote:
 
#146326
Mar 16, 2016 10:28
Vote:
 

Hi

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.

Regards

Per Gunsarfs

#146384
Mar 16, 2016 10:56
Vote:
 

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

#146504
Mar 16, 2016 16:42
Vote:
 

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

http://www.mogul.com/en/about-mogul/blog/sniff-page-parameter-in-my-controller-is-null

#146960
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.