title: How do I display the stack trace in a error view?
body: <p>I have a website with customErrors enabled which directs me to a self made view. But in case of a server error I want to show the stack trace on the SorryPage view. Why? Because then the user can copy paste the error and send it to the IT Helpdesk of our firm and this way we know what went wrong and where the error came from.</p>
  
  <p>I've seen this before but can't figure out anymore how to do this. Any help is much appreciated!</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>public ActionResult SorryPage()
      {
          return View("Error", new ErrorModel(ErrorMessages.SorryPage, "General", "Home", Labels.GoBackToPortal));
      }
  </code></pre>
  
  <p><strong>View:</strong></p>
  
  <pre><code>@using ILVO.Web.Resources
  @model ILVO.Web.Areas.General.Error._Error.ErrorModel
  @{
  ViewBag.Title = "Error pagina";
  Layout = "~/Views/Layouts/_Layout.cshtml";
  }
  
  &lt;h1&gt;@Html.Label("Error", Labels.TitleErrorPage)&lt;/h1&gt;
  &lt;br/&gt;
  &lt;h2&gt;@Model.ErrorMessage&lt;/h2&gt;
  
  &lt;br/&gt;
  &lt;div class="margin-bottom5px"&gt;
  @Html.ActionLink(Model.Button, "Index", Model.ToController, new { Area = Model.ToArea }, new { @class = "button" })
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>public class ErrorModel
  {
      public ErrorModel(string errorMessage, string toArea, string toController, string button)
      {
          ErrorMessage = errorMessage;
          ToArea = toArea;
          ToController = toController;
          Button = button;
      }
  
      public string ErrorMessage { get; set; }
      public string ToArea { get; set; }
      public string ToController { get; set; }
      public string Button { get; set; }
  }
  </code></pre>
  
  <p><strong>My cfg file:</strong></p>
  
  <pre><code>&lt;customErrors mode="RemoteOnly" xdt:Transform="Replace" defaultRedirect="~/General/Error/SorryPage"&gt;
    &lt;error statusCode="500" redirect="~/General/Error/SorryPage"/&gt;
    &lt;error statusCode="404" redirect="~/General/Error/NotFound"/&gt;
  &lt;/customErrors&gt;
  </code></pre>