あなたが設定する必要がありますあなたのweb.configファイル内
<httpErrors>
セクション
<system.webServer>
下のセクション・グループ。
この記事を参照してください。また、あなたは、あなたの質問にリンクされたエラーコントローラを使用することができます
http://www.iis.net/ConfigReference/system.webServer/httpErrors
、しかし初期の流れは、IISによって管理されるべきです。このセクションでは、コントローラに管理されているURLをIISが実行するように指示できます。
また、提案されたソリューションがブラウザで紛らわしい "200 OK"を返すので、コントローラのアクションに適切なResponse.Statusプロパティ文字列を注意してください。例
public class ErrorsController : Controller
{
public ActionResult NotFound()
{
Response.Status = "404 Not Found";
return View();
}
public ActionResult ServerError()
{
byte[] delay = new byte[1];
RandomNumberGenerator prng = new RNGCryptoServiceProvider();
prng.GetBytes(delay);
Thread.Sleep((int)delay[0]);
IDisposable disposable = prng as IDisposable;
if (disposable != null) { disposable.Dispose(); }
Response.Status = "500 Internal Server Error";
return View();
}
}
設定例:
<httpErrors defaultPath="/error.htm" errorMode="Custom" existingResponse="Replace" defaultResponseMode="ExecuteURL">
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="500" path="/errors/servererror/" responseMode="ExecuteURL" />
<error statusCode="404" path="/errors/notfound/" responseMode="ExecuteURL" />
</httpErrors>
あなたは "subStatusCode" 属性を使用して404.3とその他を制御することができます。
可能な複製[ASP.NET MVCで404を正しく処理する方法は?](http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404-in-asp-net -mvc) –