标签:object data rac 返回 ted json convert result void
一.直接使用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)返回
标签:object data rac 返回 ted json convert result void
原文地址:https://www.cnblogs.com/hongshao/p/11572231.html