为什么添加的Web表单与默认表单不同?

B. *_*non 0 asp.net webforms visual-studio visual-studio-2013

ASP.NET Webforms项目有一些默认页面("About"和"Contact"是特定的),它们具有以下类型的内容:

<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeFile="About.aspx.cs" Inherits="About" %>

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2><%: Title %>.</h2>
    <h3>Your application description page.</h3>
    <p>Use this area to provide additional information.</p>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)

然而,当您选择添加> Web窗体时,它会创建:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="DuckbilledPlatypus.aspx.cs" Inherits="DuckbilledPlatypus" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

    </div>
    </form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

为什么差异/不一致?注意:这是在Visual Studio 2013中; 我不肯定其他版本是相同的.

Hum*_*mpy 5

您没有使用母版页创建Web窗体.右键单击项目时,单击"添加项目",然后在"Web"下,它将具有"Web窗体",然后是其他类.使用母版页使用Web窗体可以为您提供所需的窗体.听起来像你使用的那个是空白网页表单,没有site.master链接到它,使用母版页的Web表单链接到site.master.