如何覆盖Authorize属性,以便可以在其上放置一个断点 [英] How can I override the Authorize attribute so I can put a breakpoint on it

查看:60
本文介绍了如何覆盖Authorize属性,以便可以在其上放置一个断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在执行以下操作,以限制使用Windows身份验证对控制器的访问.

I am currently doing the following to restrict access to a controller using windows authentication.

[Authorize(Users = @"DOMAIN\first.last")]
public class HomeController : BaseController
{

}

这目前可以正常工作,但我真正想做的是:

This works fine currently but what I really want to do is:

[Authorize(Roles = @"...")]

但是无论我担任哪个角色都行不通.

But whatever role I entered it didn't work.

我想设置一个断点,以便可以看到当前登录用户所具有的角色,但是我目前无法执行此操作.

I want to set a break-point so I can see which role the currently logged in user has, but I can't do that currently.

我是否可以从Authorize继承并创建自己的过滤器属性,以便在其中添加断点?

我想查看当前用户的角色,所以我必须在正确的位置设置一个断点.

I want to see what role the current user has, so I have to set a breakpoint at the correct spot.

我到目前为止有这个:

public class RoleFilter : AuthorizeAttribute
{

}

推荐答案

您可以创建自己的(不继承自AuthorizeAttribute),只需粘贴组成

You could create your own (not inherit from AuthorizeAttribute) and just paste in the code that makes up AuthorizeAttribute which you can get from GitHub

或者,您只需指向 MVC符号服务器

这篇关于如何覆盖Authorize属性,以便可以在其上放置一个断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆