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!

getting block data null


hi here i have a block with 2 views, i want to display view depend on situation.

so i just folled this article.block with partial view

so here my block is inherited from siteblockdata.

here is my code.

public override ActionResult Index(BlockData blockData)
var viewName = string.Empty;
JobSearch js = new JobSearch();
if (blockData == js)
viewName = "promo";
//return PartialView(string.Format("{0}{1}.cshtml", PARTIAL_VIEW_DIRECTORY, viewName));
return null;

am getting block data is null.

Mar 01, 2017 17:18

Try with currentBlock instead of blockData

Mar 01, 2017 18:09

David, that post is from the old TAP forums, which is not open to everyone :-)

Sandeep: For Episerver controllers, the model binder will check and see if the name of the parameter is currentPage/currentBlock/currentContent. If it is, it will get the current content from the routeData. So, as Dejan says, changing the parameter name to currentBlock should do the trick

Edited, Mar 01, 2017 18:50

Good point Per, the post was from 2013 so thought we might have opened them by now ;)

Mar 01, 2017 18:59

Maybe add a warning in log if a controller method (that inherits from Episervers base controllers) contains a parameter that inherits from IContent but isn't named correctly?

Mar 02, 2017 9:22
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.