Пример #1
0
 public void OnActionExecuting(ActionExecutingContext context)
 {
     if (!IsAllowAnonymousRequest(context))
     {
         if (!_authenticationHandle.AuthVerification(context.HttpContext, out string msg))
         {
             var data = new Responses.ApiCommonResponseDto <object>(401, msg);
             context.Result = new JsonResult(data)
             {
                 ContentType = "application/json;charset=utf-8"
             };
         }
     }
 }
Пример #2
0
        public async Task Invoke(HttpContext context)
        {
            //if (_authenticationHandle.AuthVerification(context, out string msg))
            //{
            //    context.Response.OnCompleted(ResponseCompletedCallback, context);
            //    await _next.Invoke(context);
            //}
            //else
            //{
            var data = new Responses.ApiCommonResponseDto <object>(401, "");

            context.Response.ContentType = "application/json;charset=utf-8";
            await context.Response.WriteAsync(data.ToJson());

            //}
        }