나는 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 오류를 확인합니다. 호스트의 잘못이 될 수 있습니까? 고맙습니다.