【发布时间】:2011-01-24 13:41:22
【问题描述】:
我已将我的 ASP.NET 2010 MVC2 系统更新到 MVC3。我还使用转换工具将一个正在进行的 MVC2 网站更新为 MVC3。我已将当前页面保留为 .aspx,包括母版页。我添加了一个新的 .cshtml 视图。除了新的基于剃刀的视图之外,所有页面都可以正常工作。
我收到以下错误
无法呈现文件“~/Views/Shared/Site.Master”,因为它不存在或不是有效页面。
它确实存在,因为它可以显示 .aspx 页面。如何添加正确的语句以在
中显示 .cshtml 页面<asp:ContentPlaceHolder ID="mainContent" runat="server">
我试过了
@RenderBody()
这给出了上述错误消息。我也试过了
<%: RenderBody() %>
但这会出错
当前上下文中不存在名称“RenderBody”
堆栈跟踪如下:
[HttpException (0x80004005): The file "~/Views/Shared/Site.Master" could not be rendered, because it does not exist or is not a valid page.]
System.Web.WebPages.Util.EnsureValidPageType(WebPageBase page, String virtualPath) +98735
System.Web.WebPages.WebPageBase.PopContext() +166
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +95
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
System.Web.Mvc.Controller.ExecuteCore() +116
System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
【问题讨论】:
标签: .net asp.net asp.net-mvc asp.net-mvc-3 razor