abp 指定 AppService中某个方法不是用驼峰命名(CamelCase)返回

一.直接使用ContentResult

 return new ContentResult
            {
                ContentType = "application/json",
                Content = JsonConvert.SerializeObject(obj,
                    new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() })
            };

二 使用MVC ResultFilter

 public class JsonSerializeFilter : IResultFilter
    {
        public void OnResultExecuted(ResultExecutedContext context)
        {

        }

        public void OnResultExecuting(ResultExecutingContext context)
        {
            var result = context.Result as ObjectResult;
            context.Result = new ObjectResult(JsonConvert.SerializeObject(
                result?.Value,
                new JsonSerializerSettings { ContractResolver = new DefaultContractResolver() }
            ));
        }
    }
//使用

  [TypeFilter(typeof(JsonSerializeFilter))]
public async Task<DataTable> Linkdata(string t, string f, string q = "")
         {//todo
         }

abp 指定 AppService中某个方法不是用驼峰命名(CamelCase)返回

上一篇:vue vue-style-loader !css-loader错误


下一篇:android studio升级3.4.1时遇到的问题