title: Redirect to controller action when any error occurs in ASP.NET MVC 5
body: <p>I need to redirect to a page when any error occurs.</p>
  
  <p><code>web.config</code></p>
  
  <pre><code>&lt;customErrors mode="On" defaultRedirect="~/Error/Index"&gt;
  &lt;/customErrors&gt;
  </code></pre>
  
  <p><code>ErrorController.cs</code>:</p>
  
  <pre><code>public class ErrorController : BaseController
  {
      // GET: Error
      public ActionResult Index(string aspxerrorpath)
      {
          SendMail("Error Web", string.Format("Usuario: {0} .Error en: {1}", UserLogged == null ? "" : UserLogged.FullName(), aspxerrorpath));
          return View("StringData","Se ha producido un error. Intentalo pasado unos minutos o envia un aviso al administrador desde el apartado de sugerencias");
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/bLuaJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bLuaJ.jpg" alt="enter image description here"></a></p>