我在DiscountASP.NET上托管我的网站。我最近遇到了404错误处理方面的问题,因为客户端并没有发送404状态码,我无法弄清楚为什么它突然出现。它曾经工作。 我试着通过一个简单的例子开始解决我的错误处理代码。我有两个页面,这两个页面都存在:ASP.NET 404处理代码在本地但不在服务器上工作
404_start.aspx:此页面旨在模拟不存在的页面。
<%@ Page Language="C#" Debug="True" Strict="True" %>
<script runat="server">
public void Page_Load()
{
Response.TrySkipIisCustomErrors = true;
Response.StatusCode = 404;
Response.Status = "404 Not Found";
Server.ClearError();
Server.Transfer("404_end.aspx");
}
</script>
<html>
<body>
Start
<br />Response.StatusCode: <%=Response.StatusCode%>
<br />Response.Status: <%=Response.Status%>
</body>
</html>
404_end.aspx:此页面是为了模拟用户看到错误消息。
<%@ Page Language="C#" Debug="True" Strict="True" %>
<html>
<body>
End
<br />Response.StatusCode: <%=Response.StatusCode%>
<br />Response.Status: <%=Response.Status%>
<br />This is extra text to fix this bug in Internet Explorer: http://queenofsubtle.com/404/?page_id=2158
<br />This is extra text to fix this bug in Internet Explorer: http://queenofsubtle.com/404/?page_id=2158
<br />This is extra text to fix this bug in Internet Explorer: http://queenofsubtle.com/404/?page_id=2158
<br />This is extra text to fix this bug in Internet Explorer: http://queenofsubtle.com/404/?page_id=2158
</body>
</html>
所以一开始页面重定向到尾页,但404错误永远不会到来通过。 Fiddler说这是一个302,然后是200.但404_end.aspx页面实际上读取的是“Response.StatusCode:404”。 在本地,Fiddler根据需要看到404错误。 它可能是主机的错?谢谢。