// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddCors(opt => opt.AddPolicy("AllowAll", builder => builder.WithOrigins("http://localhost:3000") .AllowAnyHeader().AllowAnyMethod().SetPreflightMaxAge(TimeSpan.FromSeconds(2520)) )); services.AddMvc( //opt=>opt.Filters.Add(typeof(ValidateModelStateAttribute)) ) .AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver()) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddDbContext <ApplicationDbContext>( opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection") )); ServiceInjections.InjectApplicationServices(services); services.AddAutoMapper(); services.AddElmah(); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/build"; }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddDbContext <ApplicationDbContext>( opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")) ); ServiceInjections.InjectApplicationServices(services); services.AddElmah <SqlErrorLog>( opt => opt.ConnectionString = Configuration.GetConnectionString("DefaultConnection") ); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }