如何解决此问题以下部分已定义但尚未针对布局页面“〜/ views / shared / mainmaster.cshtml”:“container”进行呈现。 [英] How to resolve this issue the following sections have been defined but have not been rendered for the layout page "~/views/shared/mainmaster.cshtml": "container".
问题描述
当我通过此异常运行该时间母版页时,会出现此问题。
以下部分已定义,但尚未针对布局页面进行渲染〜 /Views/Shared/MainMaster.cshtml:容器。
异常: -
< pre>以下部分已定义,但尚未针对布局页面〜/ Views / Shared / MainMaster.cshtml呈现:容器。
<$ p $在System.Web上的System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,TextWriter writer,WebPageRenderingBase startPage)的System.Web.WebPages.WebPageBase.PopContext()处的System.Web.WebPages.WebPageBase.VerifyRenderedBodyOrSections()处。系统中的System.Web.WebPages.WebPageBase.Write(HelperResult结果)的System.Web.WebPages.HelperResult.WriteTo(TextWriter writer)中的.WebPages.WebPageBase。<> c__DisplayClass7。< RenderPageCore> b__6(TextWriter writer) .Web.WebPages.WebPageB System.Web.Mvc上的System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext,TextWriter writer,WebPageRenderingBase startPage)上的System.Web.WebPages.WebPageBase.PopContext()中的ase.RenderSurrounding(String partialViewName,Action`1 body) System.Web上的System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)上的System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext,TextWriter writer)中的.RazorView.RenderView(ViewContext viewContext,TextWriter writer,Object实例)。 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter过滤器,ResultExecutingContext preContext)中的System.Web.Mvc.ControllerActionInvoker。<> c__DisplayClass1a。< InvokeActionResultWithFilters> b__17()的Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext,ActionResult actionResult) System.Web.Mvc.ControllerActionInvoker中的,Func`1 continuation)。<> c__DisplayClass1a。&在System.Web.Mvc.Async.AsyncControllerActionInvoker的System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext,IList`1过滤器,ActionResult actionResult)中的lt;> c__DisplayClass1c。< InvokeActionResultWithFilters> b__19()。<> c__DisplayClass25。<> c__DisplayClass2a。< BeginInvokeAction> b__20()在System.Web.Mvc.Async.AsyncControllerActionInvoker。<> c__DisplayClass25。< BeginInvokeAction> b__22(IAsyncResult asyncResult)
我尝试了什么:
我多次搜索但没有找到解决方案。
确保在您的Views文件夹中有一个名为_ViewStart.cshtml的文件,确保内容与您的母版页匹配或布局页面(这是MVC的名称)。
@ {
布局= 〜/ views / shared / mainmaster.cshtml跨度>;
}
This problem is coming when i run project that time master page through this exception.
The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/MainMaster.cshtml": "Container".
Exception:-
<pre>The following sections have been defined but have not been rendered for the layout page "~/Views/Shared/MainMaster.cshtml": "Container".
at System.Web.WebPages.WebPageBase.VerifyRenderedBodyOrSections() at System.Web.WebPages.WebPageBase.PopContext() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.WebPages.WebPageBase.<>c__DisplayClass7.<RenderPageCore>b__6(TextWriter writer) at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) at System.Web.WebPages.WebPageBase.Write(HelperResult result) at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action`1 body) at System.Web.WebPages.WebPageBase.PopContext() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<InvokeActionResultWithFilters>b__17() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1a.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<>c__DisplayClass2a.<BeginInvokeAction>b__20() at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult)
What I have tried:
I searched multiple times but no solution find.
Make sure that in your Views folder there's a file called "_ViewStart.cshtml" make sure that the content match with your 'master page' or Layout page (that's the name for MVC).
@{ Layout = "~/views/shared/mainmaster.cshtml"; }
这篇关于如何解决此问题以下部分已定义但尚未针对布局页面“〜/ views / shared / mainmaster.cshtml”:“container”进行呈现。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!