webapi返回json设置
    using Newtonsoft.Json;
    using Newtonsoft.Json.Serialization;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web.Http;

    namespace MvcApplication2
    {
        public static class WebApiConfig
        {
            public static void Register(HttpConfiguration config)
            {
                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "{controller}/{action}/{parm}",
                    defaults: new { parm = RouteParameter.Optional }
                );
                config.EnableSystemDiagnosticsTracing();
                config.Formatters.Remove(config.Formatters.XmlFormatter);
                var jsonFormatter = config.Formatters.JsonFormatter;
                jsonFormatter.SerializerSettings.Formatting = Formatting.Indented;
                jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            }
        }
    }
阅读更多
个人分类: webapi
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

webapi返回json设置

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭