title: MVC - CustomErrors does not work when setting redirectMode=“ResponseRewrite”
body: <p>I have an ASP.NET 4.0 MVC web application running on IIS 6.0 with a webconfig custom error section of:</p>
  
  <pre><code>&lt;customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/Home/Error"&gt;
    &lt;error statusCode="403" redirect="/Home/Error"/&gt;
    &lt;error statusCode="404" redirect="/Home/Error"/&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>and an error.aspx page that looks like this:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage&lt;System.Web.Mvc.HandleErrorInfo&gt;" %&gt;
  
  &lt;%@ Import Namespace="System.Security.Cryptography" %&gt;
  &lt;%@ Import Namespace="System.Threading" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"&gt;
      Error
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt;
  
      &lt;h2&gt;Error Processing your request.&lt;/h2&gt;
  
  &lt;/asp:Content&gt;
  
  &lt;asp:Content ID="Content3" ContentPlaceHolderID="Scripts" runat="server"&gt;
      &lt;script runat="server"&gt;
         void Page_Load() {
            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(); }
          }
      &lt;/script&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>Whenever i include the above "redirectMode="ResponseRewrite"" in the webconfig custom errors section the redirect to my custom errors page no longer works and i get the page error of "Server error in "/" application - resource cannot be found".  In fact the controller action is ignored as well.  When i take that setting our everything works as it should.  I am trying to incorporate Scott Gu's workaround for the Asp.net securtiy vulnerability listed here: <a href="http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx" rel="nofollow noreferrer">http://weblogs.asp.net/scottgu/archive/2010/09/18/important-asp-net-security-vulnerability.aspx</a></p>
  
  <p>Any help would be greatly appreciated.
  Thanks,
  Billy</p>