Umbraco当没有当前PublishedContentRequest时,无法呈现宏
希望你能帮助我。我在使用RenderMvcController从我的umbraco剃刀页面调用视图时遇到了这个错误。 它似乎无法在布局页面中呈现我创建的宏。
第4行:}第5行:
第6行:@ Umbraco.RenderMacro(“ExternalRedirect”)第7行:
第8行:
源文件:c: Working Git ID UMB Packages Website Views Default.cshtml行:6
堆栈跟踪:
[InvalidOperationException:当没有当前PublishedContentRequest时无法呈现宏。]
Umbraco.Web.UmbracoHelper.RenderMacro(String alias,IDictionary 2 parameters) +142 ASP._Page_Views_Default_cshtml.Execute() in c:WorkingGitIDUMB PackagesWebsiteViewsDefault.cshtml:6
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, Action2 parameters) +142 ASP._Page_Views_Default_cshtml.Execute() in c:WorkingGitIDUMB PackagesWebsiteViewsDefault.cshtml:6
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, Action2 parameters) +142 ASP._Page_Views_Default_cshtml.Execute() in c:WorkingGitIDUMB PackagesWebsiteViewsDefault.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作家)+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,Func 1 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 an umbraco data token so the umbraco view engine executes
RouteData.DataTokens["umbraco"] = model;
RouteData.DataTokens["umbraco-doc-request"] = UmbracoContext.PublishedContentRequest;
RouteData.DataTokens["umbraco-context"] = UmbracoContext;
return model;
}
}
链接地址: http://www.djcxy.com/p/72697.html
上一篇: Umbraco Cannot render a macro when there is no current PublishedContentRequest
下一篇: Why do I get a null exception on post in my DropDownListFor?