You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc.Filters;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text.Json;
|
|
using System.Threading.Tasks;
|
|
using Ys.Core.Common;
|
|
|
|
namespace djyweb_djyPaasApi
|
|
{
|
|
public class YsHttpResponseExceptionFilter : IActionFilter, IOrderedFilter
|
|
{
|
|
public int Order { get; } = int.MaxValue - 10;
|
|
public void OnActionExecuted(ActionExecutedContext context)
|
|
{
|
|
|
|
var rs = new ReturnResult<object>();
|
|
var response = context.HttpContext.Response;
|
|
response.StatusCode = 200;
|
|
|
|
response.WriteAsync(JsonSerializer.Serialize(rs, new JsonSerializerOptions(JsonSerializerDefaults.Web))).ConfigureAwait(false);
|
|
}
|
|
|
|
public void OnActionExecuting(ActionExecutingContext context)
|
|
{
|
|
|
|
var rs = new ReturnResult<object>();
|
|
var response = context.HttpContext.Response;
|
|
response.StatusCode = 200;
|
|
|
|
response.WriteAsync(JsonSerializer.Serialize(rs, new JsonSerializerOptions(JsonSerializerDefaults.Web))).ConfigureAwait(false);
|
|
}
|
|
}
|
|
}
|