title: Why should we use HandleErrorAttribute?
body: <p>I am new to MVC. I was reading about error logging in MVC. </p>
  
  <p>I came to know about <code>HandleErrorAttribute</code>. I have a question regarding that.</p>
  
  <p>Let's say we placed the <code>HandleErrorAttribute</code> in a <code>Action</code>. </p>
  
  <pre><code>&lt;!-- language: c# --&gt;
  [HandleError(View = "Error")]
  public ActionResult Index6()
  {
      throw new Exception("Something terrible happened.");
  
      return View();
  }
  </code></pre>
  
  <p>and turned on custom errors in web.config</p>
  
  <pre><code>&lt;customErrors mode="On"&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>Now if any undandled exception occured in that "Index Action", it will show the Error.cshtml which is in "Views/Shared" folder.</p>
  
  <p>But we can have the same behavior just setting some configuration under  customErrors section in web.config. like </p>
  
  <pre><code>&lt;customErrors mode="On" defaultRedirect="~/Error"&gt;
      &lt;error statusCode="404" redirect="~/Error/NotFound" /&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p>Just to mention, I have a "ErrorController" with "Index" action that returns "Views/Shared/Error.cshtml" view.</p>
  
  <p>So, my question is why should we use <code>HandleErrorAttribute</code>? is there any benefits of using that?</p>
  
  <p>Thanks</p>