using System.Web.Mvc;
namespace DbFirstApproach.Controllers
{
public class HomeController : Controller
{
public void Index()
{
HttpContext.Server.ClearError(); // Clears the previous exception.
HttpContext.Response.Clear(); // clears all content output from the buffer stream
HttpContext.Response.TrySkipIisCustomErrors = true; // Gets or sets a value that specifies whether IIS 7.0 custom errors are disabled.
HttpContext.Response.WriteFile("~/Content/404Error.html"); // '~' means home directory
HttpContext.Response.StatusCode = 404;
HttpContext.Response.ContentType = "text/html; charset=utf-8";
HttpContext.Response.End();
}
}
}
Serving Custom Error Pages Dot Net (.Net)
