public override void OnActionExecuting(ActionExecutingContext context)
 {
     try
     {
         TokenCheck.Checked(context);
     }
     catch (Exception e)
     {
         context.Result = new ContentResult()
         {
             Content     = e.Message,
             ContentType = "text/html",
             StatusCode  = 404
         };
     }
 }
Exemple #2
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            try
            {
                TokenCheck.Checked(context);

                await next.Invoke();
            }
            catch (Exception ex)
            {
                var statusCode = context.HttpContext.Response.StatusCode;
                if (ex is ArgumentException)
                {
                    statusCode = 200;
                }
                await HandleExceptionAsync(context.HttpContext, ex.Message);
            }
        }