【发布时间】:2015-08-07 07:46:47
【问题描述】:
我有一个asp.net 网站,我正在尝试配置一个 404 页面,但我似乎无法正常工作。
我的 web.config 中的代码是
<system.web>
<customErrors mode="On" defaultRedirect="ResponseRewrite">
<error statusCode="404" redirect="~/Page_Not_Found.aspx" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="~/Page_Not_Found.aspx" responseMode="Redirect"/>
</httpErrors>
</system.webServer>
错误页面 HTML
<%@ Page Title="- Page not found" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Page_Not_Found.aspx.cs" Inherits="WebApplication1.Page_Not_Found" %>
<asp:Content ID="404BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="col-xs-12 col-sm-9">
<h1>Page not found</h1>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
</div>
</asp:Content>
当我输入无效的 URL 时,我收到以下服务器错误
“/”应用程序中的服务器错误。运行时错误描述:一个 处理您的请求时发生异常。此外, 执行自定义错误页面时发生另一个异常 第一个例外。请求已终止。
我做错了什么?
我在这里和网络上查看了其他解决方案,但所有修复似乎都对我没有帮助。
【问题讨论】:
-
我猜有一些服务器错误。禁用自定义错误并检查实际的异常消息。
-
@RahulSingh 服务器错误中没有信息,因为我已经发布了我在初始帖子中得到的信息。正如我所看到的,我的项目中没有任何其他自定义错误