当使用ctrl + click在Mac OS 10.9上的Safari中触发上下文菜单事件(Context.JS)时,mousedown/up/click事件也会触发.这会导致菜单关闭.这些事件似乎是彼此异步发生的,所以stopPropagation不起作用,这似乎也会导致间歇性的行为,有时它很好,有时它不是.
有没有其他人遇到过这个问题,如果是这样,你是如何解决它/解决它的?
不幸的是,我无法向群众发布代码,但我希望那些人听起来很熟悉.
fiddle: http://jsfiddle.net/gnh2tuyj/
在我的ASP.NET Core MVC应用程序中,我有一个从AuthorizeAttribute继承并实现IAuthorizationFilter的类。
namespace MyProject.Attributes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
public class AllowGroupsAttribute : AuthorizeAttribute, IAuthorizationFilter
{
private readonly List<PermissionGroups> groupList = null;
public AllowGroupsAttribute(params PermissionGroups[] groups)
{
groupList = groups.ToList();
}
public void OnAuthorization(AuthorizationFilterContext context)
{
var executingUser = context.HttpContext.User;
//If the user is not authenticated then prevent execution
if (!executingUser.Identity.IsAuthenticated)
{
context.Result = new StatusCodeResult((int)System.Net.HttpStatusCode.Forbidden);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这使我可以用类似的东西装饰控制器方法 [AllowGroups(PermissionGroups.Admin, PermissionGroups.Level1]
我打算做的是根据列出的枚举值从appsettings.json获取组名,并检查用户是否是这些组的成员。
我的问题是,从属性类中访问应用程序设置的正确方法是什么?
c# appsettings authorize-attribute iauthorizationfilter asp.net-core-mvc