即使输入了错误的页面网址,我的asp web应用程序母版页也会呈现

时间:2016-08-20 19:21:41

标签: asp.net iis http-status-code-404 master-pages

我的asp web应用程序有几个母版页。即使我输入了错误的网址(www.domain.com/lwkenfldskfnslkfnsldkfnsdlkfnsdlkfn),主页面也会呈现网站的页眉和页脚以及其他一些内容,而不是显示iis默认的404页面错误。请帮忙

我的错误页面

<%@ Page Title="" Language="C#" MasterPageFile="~/error.Master" AutoEventWireup="true" CodeBehind="404.aspx.cs" Inherits="DiwanAlwan.error404" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">


<div class="error-404 background background-color-dark background-image-main-404">
<div class="fp-table">
<div class="fp-table-cell center"
<div class="container">
<div class="margin-bottom-40">
<h1><span class="page">page</span><span>404</span></h1>
<h2>The product not found</h2>
</div>
<p>
<span>Please try one of the following pages</span>
<a href="#" class="btn btn-lg btn-primary margin-left-10">Home Page</a>
</p>
</div><!-- /.container -->
</div>
</div>
</div><!-- /.error-404 -->


</asp:Content

我的网络配置:

<customErrors mode="On" defaultRedirect="~/404.aspx">
<error statusCode="404" redirect="~/404.aspx" />
</customErrors>

我的主页:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="error.master.cs" Inherits="DiwanAlwan.error" %>

<!DOCTYPE html>

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

1 个答案:

答案 0 :(得分:0)

您可以添加新的空白母版页并在404.aspx页面

中使用它