ASP.NET Web API异常筛选器
我正在尝试调用授权筛选器中的异常筛选器。调用异常筛选器后,它将记录来自授权筛选器的错误ASP.NET Web API异常筛选器,asp.net,asp.net-mvc,asp.net-web-api2,exceptionfilterattribute,Asp.net,Asp.net Mvc,Asp.net Web Api2,Exceptionfilterattribute,我正在尝试调用授权筛选器中的异常筛选器。调用异常筛选器后,它将记录来自授权筛选器的错误 Public Class AuthFilterAttribute Inherits AuthorizationFilterAttribute Public Overrides Sub OnAuthorization(ByVal actionContext As HttpActionContext) If actionContext.Request.Re
Public Class AuthFilterAttribute
Inherits AuthorizationFilterAttribute
Public Overrides Sub OnAuthorization(ByVal actionContext As HttpActionContext)
If actionContext.Request.RequestUri.Scheme <> Uri.UriSchemeHttps Then
actionContext.Response = New HttpResponseMessage(System.Net.HttpStatusCode.Forbidden) With
{
.ReasonPhrase = "HTTPS required"
}
End If
If actionContext.Response IsNot Nothing Then
Throw New HttpResponseException(actionContext.Response) ''''' Calling the exception filter here '''
End If
MyBase.OnAuthorization(actionContext)
End Sub
End Class
Public Overrides Sub OnException(ByVal filterContext As HttpActionExecutedContext)
If filterContext IsNot Nothing Then
''' Logging my error here '''
''' What to send back the error code and message coming from authorizaton filter '''
End If
End Sub