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

Vote:
 

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.

#175778
Mar 01, 2017 17:18
Vote:
 

Try with currentBlock instead of blockData

#175781
Mar 01, 2017 18:09
Vote:
 

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

#175784
Edited, Mar 01, 2017 18:50
Vote:
 

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

#175785
Mar 01, 2017 18:59
Vote:
 

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?

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