私はDiscountASP.NETで自分のサイトをホストしています。クライアントに404ステータスコードが送信されていないため、最近404エラー処理で問題が発生しましたが、なぜ突然起動したのかわかりません。以前は機能していました。簡単な例から始めて、エラー処理コードを回避しようとしました。私には2つのページがあり、どちらも存在します。
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エラーを認識します。それはホストのせいでしょうか?ありがとうございました。