How to measure cpu utilization (or other ressource) between IAsyncAuthorizationFilter and IAuthorizationFilter
I think Async it is better but of how many
Could you teld me wich indicator to monitor ?
http://techgenix.com/Windows_2003_Performance_Monitor/
https://msdn.microsoft.com/fr-fr/library/system.diagnostics.performancecounter%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
using Microsoft.AspNetCore.Mvc; public class AuthorizeActionAttribute : TypeFilterAttribute { public AuthorizeActionAttribute(string identifiant, AuthorizedAction action) : base(typeof(AuthorizeActionFilter/*or AuthorizeActionFilterAsync*/)) { Arguments = new object[] { new CheckAction(identifiant, action) }; } } public enum AuthorizedAction : int { None = 0, CreateUser = 1,// 2^0 = 1 ... } public class CheckAction : IAuthorizationRequirement { public CheckAction(string trackArgument, AuthorizedAction action) { TrackArgument = trackArgument; Action = action; } public string TrackArgument { get; set; } public AuthorizedAction Action { get; set; } } //=>Async using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; public class AuthorizeActionFilterAsync : IAsyncAuthorizationFilter { private readonly IWWWManager manager; private readonly CheckAction checkAction; public AuthorizeActionFilterAsync(IWWWManager manager, CheckAction checkAction) { this.manager = manager; this.checkAction = checkAction; } public virtual async Task OnAuthorizationAsync(AuthorizationFilterContext context) { string identfiant = (string)context.RouteData.Values[checkAction.TrackArgument]; //Check something if (checkAction.Action == AuthorizedAction.CreateDelegate) { if (!context.HttpContext.User.IsInRole("AdminRight")) context.Result = new ForbidResult(); var info = await manager.Info(context.HttpContext.User.Identity.Name); if (info == null) context.Result = new ForbidResult(); } } } //=>No Async using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; public class AuthorizeActionFilter : IAuthorizationFilter { private readonly IWWWManager manager; private readonly CheckAction checkAction; public AuthorizeActionFilter(IWWWManager manager, CheckAction checkAction) { this.manager = manager; this.checkAction = checkAction; } public async void OnAuthorization(AuthorizationFilterContext context) { string identfiant = (string)context.RouteData.Values[checkAction.TrackArgument]; //Check something if (checkAction.Action == AuthorizedAction.CreateDelegate) { if (!context.HttpContext.User.IsInRole("AdminRight")) context.Result = new ForbidResult(); var info = await manager.Info(context.HttpContext.User.Identity.Name); if (info == null) context.Result = new ForbidResult(); } } } //Exemple [HttpPost, Route("{identifiant}/create")] [AuthorizeAction("identifiant", AuthorizedAction.CreateUser)] public async Task<IActionResult> CreateUser(string identifiant, CreateUser user) { //TODO }