ExceptionContext - How to find out the type of http action?
Trying to improve exception handling, how do I know if the exception was GET or POST?
protected override void OnException(ExceptionContext filterContext)
{
var action = filterContext.RouteData.Values["action"];
var controller = filterContext.RouteData.Values["controller"];
var httpActionType = filterContext.RouteData.Values["????????"]
}
+3
DW
source
to share
1 answer
There are many ways to get to this value. One way is to access it through the filter context directly
var httpActionType = filterContext.HttpContext.Request.HttpMethod;
+1
Nkosi
source
to share