Exemple #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //跨域策略
            CorsConfig.Config(services, "AllowOrigin");

            services.AddMvc(options =>
            {
                //将过滤器注册为全局过滤器
                //options.Filters.Add(new RequestOperationFilter());
            }).AddJsonOptions(options =>
            {
                //忽略循环引用
                options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                //设置时间格式
                options.SerializerSettings.DateFormatString = "yyyy-MM-dd";
            });

            //依赖注入注册
            DIConfig.Configure(services);
        }