Reputation: 480
I have created an ExceptionFilter:
public class LogException : FilterAttribute, IExceptionFilter
{
void IExceptionFilter.OnException(ExceptionContext filterContext)
{
Utility.Log.LogMe(filterContext.Exception);
filterContext.ExceptionHandled = true;
}
}
I want to redirect the user to login page whenever this method is hit. How can i do that?
Upvotes: 4
Views: 4230
Reputation:
It's important that your ExceptionHandled
assignment stays in there, that's a good call, but to redirect too:
filterContext.Result = new RedirectToRouteResult(
new RouteValueDictionary
{
{ "controller", "Account" },
{ "action", "LogIn" }
});
};
Upvotes: 11