c# - Umbraco Cannot render a macro when there is no current PublishedContentRequest -
hope can me.i encountered error upon calling view umbraco razor page using rendermvccontroller. it's seems can't render created macro inside layout page.
line 4: } line 5:
line 6: @umbraco.rendermacro("externalredirect") line 7:
line 8:
source file: c:\working\git\id\umb packages\website\views\default.cshtml line: 6
stack trace:
[invalidoperationexception: cannot render macro when there no current publishedcontentrequest.]
umbraco.web.umbracohelper.rendermacro(string alias, idictionary2 parameters) +142 asp._page_views_default_cshtml.execute() in c:\working\git\id\umb packages\website\views\default.cshtml:6
1 body) +233
system.web.webpages.webpagebase.executepagehierarchy() +280
system.web.mvc.webviewpage.executepagehierarchy() +125
system.web.webpages.webpagebase.executepagehierarchy(webpagecontext pagecontext, textwriter writer, webpagerenderingbase startpage) +196
system.web.webpages.webpagebase.write(helperresult result) +89
system.web.webpages.webpagebase.rendersurrounding(string partialviewname, action
system.web.webpages.webpagebase.popcontext() +287
umbraco.core.profiling.profilingview.render(viewcontext viewcontext, textwriter writer) +140
system.web.mvc.viewresultbase.executeresult(controllercontext context) +378 system.web.mvc.<>c__displayclass1a.b__17() +33 system.web.mvc.controlleractioninvoker.invokeactionresultfilter(iresultfilter filter, resultexecutingcontext precontext, func1 continuation) +799724 system.web.mvc.controlleractioninvoker.invokeactionresultfilter(iresultfilter filter, resultexecutingcontext precontext, func
1 continuation) +799724 system.web.mvc.controlleractioninvoker.invokeactionresultwithfilters(controllercontext controllercontext, ilist`1 filters, actionresult actionresult) +263
system.web.mvc.async.<>c__displayclass25.b__22(iasyncresult asyncresult) +787092
system.web.mvc.<>c__displayclass1d.b__18(iasyncresult asyncresult) +28
system.web.mvc.async.<>c__displayclass4.b__3(iasyncresult ar) +15 system.web.mvc.controller.endexecutecore(iasyncresult asyncresult) +65
system.web.mvc.async.<>c__displayclass4.b__3(iasyncresult ar) +15 system.web.mvc.controller.endexecute(iasyncresult asyncresult) +51
system.web.mvc.<>c__displayclass8.b__3(iasyncresult asyncresult) +42
system.web.mvc.async.<>c__displayclass4.b__3(iasyncresult ar) +15 system.web.mvc.mvchandler.endprocessrequest(iasyncresult asyncresult) +51
system.web.callhandlerexecutionstep.system.web.httpapplication.iexecutionstep.execute() +606 system.web.httpapplication.executestep(iexecutionstep step, boolean& completedsynchronously) +288
public class blogcontroller : rendermvccontroller { public blogcontroller() : this(umbracocontext.current) { } public blogcontroller(umbracocontext umbracocontext) : base(umbracocontext) { } public actionresult index(int id) { return view("12321"); } public actionresult yearpost(int id) { string test = "blog"; var criteria = examinemanager.instance.defaultsearchprovider.createsearchcriteria("content"); var filterblogs = id == 0 ? criteria.nodetypealias("blog") : criteria.nodename("blog"); var result = umbraco.typedsearch(filterblogs.compile()).toarray().first(); var rendermodel = createrendermodel(result); string viewblog = "blogpostpage"; return view(viewblog, rendermodel); } private rendermodel createrendermodel(ipublishedcontent content) { var model = new rendermodel(content,cultureinfo.currentuiculture); //add umbraco data token umbraco view engine executes routedata.datatokens["umbraco"] = model; routedata.datatokens["umbraco-doc-request"] = umbracocontext.publishedcontentrequest; routedata.datatokens["umbraco-context"] = umbracocontext; return model; } }
Comments
Post a Comment