title: display a general error page in MVC
body: <p>I have an MVC C# App and I need to display a specific view to the user when an error occurs.</p>
  
  <p>So if the error is code=200, code=404, code=500 or any other error I just have to display the Error View located in <code>~/Views/Shared/Error.cshtml</code> with a general message.</p>
  
  <p>So my question: is it enough to add this in the global.asax</p>
  
  <pre><code>public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  {
      filters.Add(new HandleErrorAttribute());
  }
  </code></pre>
  
  <p>or do I also need to modify my web.config this way:</p>
  
  <pre><code>&lt;customErrors mode="RemoteOnly"&gt;
      &lt;error statusCode="404" redirect="~/Views/Shared/Error.cshtml"/&gt;
      &lt;error statusCode="500" redirect="~/Views/Shared/Error.cshtml"/&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>only one of the options is necessary or do I have to add the two of them?</p>