本文介绍了为什么在我的自定义AuthorizationFilterAttribute中两次调用OnAuthorization?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么OnAuthorization为我的直接AuthorizationFilterAttribute叫了两次?

Why is OnAuthorization called twice for my straight forward AuthorizationFilterAttribute?

public class ApiAuthenticateAttribute : AuthorizationFilterAttribute
{
   public void override OnAuthorization(System.Web.Http.Controllers.HttpActionContext actionContext)
    {
        if(NotAuthorized())
            throw new Exception();

    }
}

首次调用堆栈

推荐答案

问题出在Ninject.Web.WebApi.由于某种原因,它两次注册了过滤器.将软件包更新到最新版本(v 3.2.1)可以解决此问题.

The problem was with Ninject.Web.WebApi. For some reason it was registering the filter twice. Updating the package to latest (v 3.2.1) fixed the issue.

这篇关于为什么在我的自定义AuthorizationFilterAttribute中两次调用OnAuthorization?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 13:23