【发布时间】:2015-10-21 16:46:31
【问题描述】:
我正在尝试创建一个非常简单的 asp.net masterpage 站点,在我上传到主机之前一切顺利。使用以下 web.config
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
</configuration>
我被告知要添加
<customErrors mode="Off"/>
当我添加时
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off"/>
</system.web>
我收到新错误
在母版页“/MasterPage.master”中找不到 ContentPlaceHolder“ContentPlaceHolder1”,请在内容页中验证内容控件的 ContentPlaceHolderID 属性。
母版页代码似乎是正确的
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>test_configprob02</title></head>
<body>
<form id="mainForm" runat="server">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form></body></html>
default.aspx 代码
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<p>Lorem ipsum dolor ipsum.</p>
</asp:Content>
难倒。
这是浏览器中显示的内容-
“/”应用程序中的服务器错误。
Cannot find ContentPlaceHolder 'bodyPL' in the master page '/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.
说明:在执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
Exception Details: System.Web.HttpException: Cannot find ContentPlaceHolder 'bodyPL' in the master page '/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.
来源错误:
在执行当前 Web 请求期间生成了未处理的异常。可以使用下面的异常堆栈跟踪来识别有关异常起源和位置的信息。
堆栈跟踪:
[HttpException (0x80004005): Cannot find ContentPlaceHolder 'bodyPL' in the master page '/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.]
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +797
System.Web.UI.Page.get_Master() +54
System.Web.UI.Page.ApplyMasterPage() +14
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +335
版本信息:Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.0.30319.34249
【问题讨论】:
-
母版页中是否有“bodyPL”?如果不是这样就可以解释了。
-
@tpugh 将此
<asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder>添加到内容上方的主页面和默认页面中