Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ASP.NET Web API异常筛选器_Asp.net_Asp.net Mvc_Asp.net Web Api2_Exceptionfilterattribute - Fatal编程技术网

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