Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.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
C# 从未调用Customer ActionFilterAttribute OnActionExecuting override_C#_Asp.net Mvc_Custom Attributes_Onactionexecuting - Fatal编程技术网

C# 从未调用Customer ActionFilterAttribute OnActionExecuting override

C# 从未调用Customer ActionFilterAttribute OnActionExecuting override,c#,asp.net-mvc,custom-attributes,onactionexecuting,C#,Asp.net Mvc,Custom Attributes,Onactionexecuting,我使用的是MVC4 我对这个从System.Web.Mvc.ActionFilterAttribute继承的客户属性进行编码 我在UserController中的action Manager上使用它 我在属性构造函数、重写方法OnActionExecuting和UserController中放置了一个断点,当我在调试模式下通过浏览器调用操作url时,只有我的控制器断点被触发,即使我没有经过身份验证,我也会在页面上着陆。。 我做错了什么 提前感谢。您的代码应该可以工作。可能您在路由等方面遇到了问题

我使用的是MVC4

我对这个从System.Web.Mvc.ActionFilterAttribute继承的客户属性进行编码

我在UserController中的action Manager上使用它

我在属性构造函数、重写方法OnActionExecuting和UserController中放置了一个断点,当我在调试模式下通过浏览器调用操作url时,只有我的控制器断点被触发,即使我没有经过身份验证,我也会在页面上着陆。。 我做错了什么


提前感谢。

您的代码应该可以工作。可能您在路由等方面遇到了问题。

看来我并不完全在MVC4中,但几乎在MVC5中。我只需要在我的web.config上做一些更新来解决我的问题。。
我发现了我的救命恩典

不,我的路由是好的,我的控制器方法中的断点正在触发,但属性中的断点没有触发。在这种情况下,只有在项目中查看此功能时,我才能找到它。您还需要了解哪些其他信息,以确定它是否正常?
public class AuthorizedAttribute : ActionFilterAttribute
{    
    public AccessLevel Threshold { get; set; }

    public AuthorizedAttribute()
    {
        Threshold = AccessLevel.Anonymous;
    }

    public AuthorizedAttribute(AccessLevel threshold)
    {
        Threshold = threshold;
    }

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {
        //some actions
        base.OnActionExecuting(filterContext);
    }
}
public class UserController : Controller
{
    [HttpGet]
    [Authorized(AccessLevel.Administrator)]
    public ViewResult Manage()
    {
         return View();
    }
}