简体   繁体   中英

how to view master page in browser

just learning master page, i have a master page which include a content. but how to view the page .master in browser? what it the url?

<%@ 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></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

No, you can not view master page (.master) in browser - because it is not an actual page but a Control which encloses the content of .aspx pages.

When users request the content pages(.aspx), they merge with the master page (.master) to produce output that combines the layout of the master page with the content from the content page.

A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application.

在此处输入图片说明

For more information please read - ASP.NET Master Pages

您可以在aspx页面中单独使用它并直接查看aspx页面

You can not directly view a master page. It's more like a shell\\template of what the page is supposed to look like.

However, you can create a new page using the master page you have here, and call that page's Url.

You cannot view a master page in the browser. It is not a renderable page.

The master page is referenced by regular .aspx pages with the Master attribute of the @Page directive. The rendering process merges the contents of the page and the master and the results are returned to the client, but the URL is that of the page.

If you wish to see the master page as it is rendered, create an empty page that uses that master, then view the page in your browser.

Run This Default2.aspx page to show this page content into master page.

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    This Is Your Master Page Content....
</asp:Content>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM