1
votes

I'm trying to create a very simple asp.net masterpage site, all is going well until I upload to host. With the following 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> 

I'm told to add

<customErrors mode="Off"/>  

When I do add that

<system.web>
  <compilation debug="true" targetFramework="4.5" />
  <httpRuntime targetFramework="4.5" />
  <customErrors mode="Off"/>
</system.web>

I get new error

Cannot find ContentPlaceHolder 'ContentPlaceHolder1' in the master page '/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.

Masterpage code seems to be correct

<%@ 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 code

<%@ 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>

Stumped.

Here's what shows in the browser-

Server Error in '/' Application.

Cannot find ContentPlaceHolder 'bodyPL' in the master page '/MasterPage.master', verify content control's ContentPlaceHolderID attribute in the content page.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[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

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249

2
Is there a "bodyPL" in the Master Page? If not that would explain it. - JB King
@tpugh add this <asp:ContentPlaceHolder ID="head" runat="server"> </asp:ContentPlaceHolder> in master and default page above the content - The Blue Shirt Developer

2 Answers

0
votes

Try giving the ContentPlaceHolder control a new id something like "body" then reset the ContentPlaceHolderId attribute of the Content control and see where that gets you, I can't see anything wrong with it either.

Are there any build errors when you compile the project?

BTW if you don't know, apologies if you do;

Custom errors is a setting in the web config that you can set

Off - which will display .net error messages such as the one you're seeing.

On - which will allow you to specify redirects to custom pages for specific error codes for example:

RemoteOnly - which will allow you to see error message on the server that the website resides on but still show your custom error page to visitors

Also good to know: that you can set a default url for errors

Further reading:

https://msdn.microsoft.com/en-gb/library/h0hfz6fc(v=vs.85).aspx

Hope this helps.

0
votes

If it's working on your local environment and not the host, it's probably the hosting environment. Confirm your app pool is set to run using the correct .net framework. Also, confirm the managed pipeline mode is "Integrated'.

Was there ever an element named "bodyPL"?