title: ASP.NET MVC Custom Error Page, one page for multiple errors
body: <p>I am trying to add custom error page to my web application and I did the following based on some answers on stack overflow,
  <strong>The Controller</strong></p>
  <pre><code>public class ErrorController : Controller
  {
      public ViewResult Index()
      {
          return View(&quot;Error&quot;);
      }
      public ViewResult NotFound()
      {
          Response.StatusCode = 404;  //you may want to set this to 200
          return View(&quot;NotFound&quot;);
      }
  
  }
  </code></pre>
  <p>I have added two views, Error.cshtml and NotFound.cshtml</p>
  <p>and I added the following to the web.config file:</p>
  <pre><code>&lt;customErrors mode=&quot;On&quot; defaultRedirect=&quot;~/Error&quot;&gt;
    &lt;error redirect=&quot;~/Error/Error&quot; statusCode=&quot;404&quot; /&gt;
    
    
  &lt;/customErrors&gt;
  </code></pre>
  <p>I need to have one page for all errors, or for the same error category, for example one page for all 400s errors so instead of doing</p>
  <pre><code> &lt;error redirect=&quot;~/Error/Error&quot; statusCode=&quot;400&quot; /&gt;
   &lt;error redirect=&quot;~/Error/Error&quot; statusCode=&quot;401&quot; /&gt;
   &lt;error redirect=&quot;~/Error/Error&quot; statusCode=&quot;402&quot; /&gt;
  </code></pre>
  <p>do something like</p>
  <pre><code> &lt;error redirect=&quot;~/Error/Error&quot; statusCode=&quot;40***&quot; /&gt;
  </code></pre>