Custom error pages in ASP.NET MVC

Excellent blog post by Ben Foster:
Custom error pages in ASP.NET MVC. Easy, right? – Ben Foster

My extra take on it was to create content in the static .html pages and use an iframe inside the aspx based pages (to reuse the content easily).

E.g: (my 500 error page is named Error500.aspx)

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Error500.aspx.cs" Inherits="Error500" %>
<% Response.StatusCode = 500; %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>An error has occurred - 500</title>
    <style>iframe, html, body { height: 100%; width: 100%; margin: 0; border: 0; padding: 0; }</style>
</head>
<body>
    <iframe src="Error500.html"></iframe>
</body>
</html>

 

Leave a Reply

Your email address will not be published. Required fields are marked *