|
|
|
@ -2,6 +2,7 @@ using System.Web.Http;
|
|
|
|
using System.Web.Http.Cors;
|
|
|
|
using System.Web.Http.Cors;
|
|
|
|
using CncWebApi.Filters;
|
|
|
|
using CncWebApi.Filters;
|
|
|
|
using CncWebApi.Infrastructure;
|
|
|
|
using CncWebApi.Infrastructure;
|
|
|
|
|
|
|
|
using Newtonsoft.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
|
|
namespace CncWebApi.App_Start
|
|
|
|
namespace CncWebApi.App_Start
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -29,7 +30,9 @@ namespace CncWebApi.App_Start
|
|
|
|
// 全局异常过滤器
|
|
|
|
// 全局异常过滤器
|
|
|
|
config.Filters.Add(new GlobalExceptionFilter());
|
|
|
|
config.Filters.Add(new GlobalExceptionFilter());
|
|
|
|
|
|
|
|
|
|
|
|
// 统一JSON序列化设置
|
|
|
|
// 统一JSON序列化设置:camelCase输出(Code→code, Message→message, Data→data)
|
|
|
|
|
|
|
|
config.Formatters.JsonFormatter.SerializerSettings.ContractResolver =
|
|
|
|
|
|
|
|
new CamelCasePropertyNamesContractResolver();
|
|
|
|
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling =
|
|
|
|
config.Formatters.JsonFormatter.SerializerSettings.NullValueHandling =
|
|
|
|
Newtonsoft.Json.NullValueHandling.Ignore;
|
|
|
|
Newtonsoft.Json.NullValueHandling.Ignore;
|
|
|
|
config.Formatters.JsonFormatter.SerializerSettings.DateFormatString =
|
|
|
|
config.Formatters.JsonFormatter.SerializerSettings.DateFormatString =
|
|
|
|
|