title: MVC Custom Error handling issue
body: <p>I'm currently working on an MVC application.  My issue is that I can't get my customerror handling to work correctly.</p>
  
  <p>So essentially what happens is I throw an exception to test this in a controller.  Then the application should redirect the user to ~/Shared/Errors.cshtml but for some reason it doesn't do this.</p>
  
  <p>Here is the code.</p>
  
  <p>Exception being thrown:</p>
  
  <pre><code>throw new Exception("Something went wrong");
  </code></pre>
  
  <p>Webconfig file:</p>
  
  <pre><code>&lt;customErrors mode="RemoteOnly"/&gt;
  </code></pre>
  
  <p>ErrorController Code:</p>
  
  <pre><code>  public class ErrorController : Controller
      {
          //
          // GET: /Error/
      public ActionResult Index()
      {
          return View();
      }
  
  }
  </code></pre>
  
  <p>Code used in Error.cshtml:</p>
  
  <pre><code>@model System.Web.Mvc.HandleErrorInfo
  @{
      Layout = "_Layout.cshtml";
      ViewBag.Title = "Error";
  }
  &lt;div class="list-header clearfix"&gt;
      &lt;span&gt;Error&lt;/span&gt;
  &lt;/div&gt;
  &lt;div class="list-sfs-holder"&gt;
      &lt;div class="alert alert-error"&gt;
          An unexpected error has occurred. Please contact the system administrator.
      &lt;/div&gt;
      @if (Model != null &amp;&amp; HttpContext.Current.IsDebuggingEnabled)
      {
          &lt;div&gt;
              &lt;p&gt;
                  &lt;b&gt;Exception:&lt;/b&gt; @Model.Exception.Message&lt;br /&gt;
                  &lt;b&gt;Controller:&lt;/b&gt; @Model.ControllerName&lt;br /&gt;
                  &lt;b&gt;Action:&lt;/b&gt; @Model.ActionName
              &lt;/p&gt;
              &lt;div style="overflow:scroll"&gt;
                  &lt;pre&gt;
                      @Model.Exception.StackTrace
                  &lt;/pre&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>Thanks in advance for any help you can give</p>