I am using PostSharp aspects for exception handling inside of Controller in ASP.NET MVC project. Simplified code is like this:
[ExceptionAspect(AspectPriority = 1)]
public ActionResult MarkeSettings()
{
try{
SaveData();
NotifyUser("success");
return RedirectToAction("A");
}
catch(Exception ex){
NotifyUser(ex.Message);
return RedirectToAction("B");
}
}
I have class ExceptionAspect
that inherits from OnExceptionAspect
class. In OnException(MethodExecutionArgs args)
method I set args.FlowBehavior = FlowBehavior.Continue;
.
So, how can I get rid of this try/catch
block and control the program execution flow and take an appropriate action for ReturnRedirectToAction()
? I read about Sharing state between advices , but couldn't figure out how to apply it on my problem.