asp.net mvc 4 - ViewContext.ParentActionViewContext is null when trying to access parent ContentArea in EPiServer -


i'm trying use approach shown here allow blocks in episerver query index within parent contentarea. in project (project a) , trying again in new project (project b). reason in new project, viewcontext.parentactionviewcontext null. started comparing differences between 2 , notice in project a, ischildaction true , routedata.datatokens contains 1 key = 'parentactiondatacontext', in project b, ischildaction false , routedata.datatokens contains keys main request. ok, given description of parentactionviewcontext property is:

an object contains view context information parent action method.

it makes sense null in project b if there no child action. problem is, don't know why project executes rendering contentarea child action project b not. comparing call stacks, can see branches off in 2 different directions within episerver assembly (top 2 frames of each stack below):

project a

episerver.dll!episerver.web.mvc.partialrequest.renderaction(system.web.mvc.htmlhelper helper, string action, string controller, object routevalues) unknown episerver.dll!episerver.web.mvc.mvccontentrenderer.render(system.web.mvc.htmlhelper helper, episerver.web.mvc.partialrequest partialrequesthandler, episerver.core.icontentdata contentdata, episerver.dataabstraction.templatemodel templatemodel) unknown episerver.dll!episerver.web.mvc.html.icontentdataextensions.rendercontentdata(system.web.mvc.htmlhelper html, episerver.core.icontentdata contentdata, bool iscontentincontentarea, episerver.dataabstraction.templatemodel templatemodel, episerver.web.mvc.icontentrenderer contentrenderer)  unknown episerver.dll!episerver.web.mvc.html.contentarearenderer.rendercontentareaitem(system.web.mvc.htmlhelper htmlhelper, episerver.core.contentareaitem contentareaitem, string templatetag, string htmltag, string cssclass)   unknown episerver.dll!episerver.web.mvc.html.contentarearenderer.rendercontentareaitems(system.web.mvc.htmlhelper htmlhelper, system.collections.generic.ienumerable<episerver.core.contentareaitem> contentareaitems)  unknown episerver.dll!episerver.web.mvc.html.contentarearenderer.render(system.web.mvc.htmlhelper htmlhelper, episerver.core.contentarea contentarea)   unknown episerver.dll!episerver.web.mvc.html.contentareaextensions.rendercontentarea(system.web.mvc.htmlhelper htmlhelper, episerver.core.contentarea contentarea)  unknown app_web_zaun2obg.dll!asp.util_views_shared_displaytemplates_contentarea_ascx.__render__control1(system.web.ui.htmltextwriter __w, system.web.ui.control parametercontainer) line 4  c# 

project b

episerver.dll!episerver.web.mvc.mvccontentrenderer.handlerendertemplatewithviewengine(system.web.mvc.htmlhelper helper, episerver.core.icontentdata contentdata, episerver.dataabstraction.templatemodel templatemodel) unknown episerver.dll!episerver.web.mvc.mvccontentrenderer.render(system.web.mvc.htmlhelper helper, episerver.web.mvc.partialrequest partialrequesthandler, episerver.core.icontentdata contentdata, episerver.dataabstraction.templatemodel templatemodel) unknown episerver.dll!episerver.web.mvc.html.icontentdataextensions.rendercontentdata(system.web.mvc.htmlhelper html, episerver.core.icontentdata contentdata, bool iscontentincontentarea, episerver.dataabstraction.templatemodel templatemodel, episerver.web.mvc.icontentrenderer contentrenderer)  unknown episerver.dll!episerver.web.mvc.html.contentarearenderer.rendercontentareaitem(system.web.mvc.htmlhelper htmlhelper, episerver.core.contentareaitem contentareaitem, string templatetag, string htmltag, string cssclass)   unknown episerver.dll!episerver.web.mvc.html.contentarearenderer.rendercontentareaitems(system.web.mvc.htmlhelper htmlhelper, system.collections.generic.ienumerable<episerver.core.contentareaitem> contentareaitems)  unknown episerver.dll!episerver.web.mvc.html.contentarearenderer.render(system.web.mvc.htmlhelper htmlhelper, episerver.core.contentarea contentarea)   unknown episerver.dll!episerver.web.mvc.html.contentareaextensions.rendercontentarea(system.web.mvc.htmlhelper htmlhelper, episerver.core.contentarea contentarea)  unknown app_web_myevwxkt.dll!asp.util_views_shared_displaytemplates_contentarea_ascx.__render__control1(system.web.ui.htmltextwriter __w, system.web.ui.control parametercontainer) line 4  c# 

but call both same way:

project a:

@html.propertyfor(m => m.currentpage.wallblocks) 

project b:

@html.propertyfor(m => m.currentpage.departmentalsupportblocks) 

any idea what's going on or how can make work can @ parent contentarea in html helper?

i found problem. correct in thinking parentactionviewcontext null because block not being executed child view. reason seems because block did not have controller. looks episerver render blocks have controller child actions, not have controller part of same request. guess reason why it's recommended not use controller blocks efficiency reasons. however, if need information parent contentarea, seems need have controller.

p.s. make sure return partialview(...) not view(...) block controller don't spend couple hours trying figure out why it's yelling @ saying,

the model item passed dictionary of type 'castle.proxies.[myblock]proxy', dictionary requires model item of type '[my default layout's model type]'


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -