I have user errors included in webconfig and redirect to "/ Error / Trouble". It works the way it was designed. Elmah error. An error image is also displayed.
The problem is that I want to check for an error in the Trouble action of my error controller. When an error occurs, how do you access it after MVC redirects you to a special error handler?
I throw an exception if CurrentUser is null:
if (CurrentUser == null)
{
var message = String.Format("{0} is not known. Please contact your administrator.", context.HttpContext.User.Identity.Name);
throw new Exception(message, new Exception("Inner Exception"));
}
I want to have access to this in my custom error handler (Error / Failure). How do you access the exception?
Here is my action:
public ActionResult Trouble()
{
return View("Error");
}
Here is my view:
@model System.Web.Mvc.HandleErrorInfo
<h2>
Sorry, an error occurred while processing your request.
</h2>
@if (Model != null)
{
<p>@Model.Exception.Message</p>
<p>@Model.Exception.GetType().Name<br />
thrown in @Model.ControllerName @Model.ActionName</p>
<p>Error Details:</p>
<p>@Model.Exception.Message</p>
}
System.Web.Mvc.HandleErrorInfo is a model for my review of problems, and it is empty. Thank you for your help.