I am developing a MVC 5 internet application and have a question in regards to passing an object
to a shared view
.
I have a view
called CustomError.cshtml
in the shared folder. This view
has the following model type: @model CanFindLocation.ViewModels.CustomErrorViewModel
How can I pass an object of type CanFindLocation.ViewModels.CustomErrorViewModel
to this view
from the protected override void OnException(ExceptionContext filterContext)
function in a controller
?
Here is my code:
protected override void OnException(ExceptionContext filterContext)
{
Exception e = filterContext.Exception;
if (e is HttpRequestValidationException)
{
filterContext.ExceptionHandled = false;
customErrorViewModel = customErrorService.GetDefaultCustomError(customErrorType, "Test message.");
RedirectToAction("CustomError", customErrorViewModel);
}
}
Instead of the view
being shown, the following function is called:
protected void Application_Error(object sender, EventArgs e)
Thanks in advance.