public Task <FilterResult> FilterAsync(FilterAttribute attribute, MiddlewareData data) { var principal = data.Features.RequireOne <AuthenticationFeature>().Principal; if (!principal.IsAuthenticated()) { var message = new BaseOutMessage() { Text = "Unauthorized access" }; var result = FilterResult.BreakExecution(data.AddRenderMessageFeature(message)); return(Task.FromResult(result)); } return(Task.FromResult(FilterResult.NextFilter(data))); }