Reputation: 731
I have a custom Error Handler class attribute in MVC3 application. which takes ExceptionContext
as parameter. I want to redirect to error.html page after writing the error log.
I have tried as bellow but it does not work. Any suggestions please?
context.Result = new RedirectResult("~/Error.html");
Custom Error Handler
private static void LogUnhandledException(ExceptionContext context)
{
var e = context.Exception;
ErrorLog.Error(1, e.Message, e, "test");
// Redirect to Error Page
//context.Result = new RedirectResult("~/Error.htm");
context.Result = new FilePathResult("~/Error.htm", "text/html");
}
Thanks
Upvotes: 1
Views: 4407
Reputation: 14100
try this
context.Result = new FilePathResult("~/Error.html", "text/html");
And i think you should do this in the Error
Action
not in the HandleErrorAttribute
:
public ActionResult Error(){
var result = new FilePathResult("~/Error.html", "text/html");
return result;
}
Upvotes: 3