public void ConfigureServices(IServiceCollection services) { #region Register DB Context ConfigDbContext.Register(Configuration, services); #endregion #region CORS var allowedCors = Configuration.GetSection("CORS") .AsEnumerable() .Where(h => !string.IsNullOrEmpty(h.Value)) .Select(h => h.Value).ToArray(); services.AddCors(options => { options.AddPolicy(_allowOriginPolicy, builder => { builder.WithOrigins(allowedCors) .SetIsOriginAllowedToAllowWildcardSubdomains() .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); }); }); #endregion services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0) .AddNewtonsoftJson(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); services.AddSwaggerServices(); services.AddControllers() .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null); #region Register Application Services ConfigServices.Register(services); #endregion }