public Task <CorsPolicy> GetPolicyAsync(HttpContext context, string policyName) { FlightPlanDBContext flightPlanDBContext = new FlightPlanDBContext(); var arrayOrigins = (from server in flightPlanDBContext.Servers.ToList() select server.ServerURL.Substring(0, server.ServerURL.Length - 1)).ToArray(); var retval = new CorsPolicy(); retval.SupportsCredentials = false; foreach (var each in arrayOrigins) { retval.Origins.Add(each); } return(Task.FromResult(retval)); }
public void ConfigureServices(IServiceCollection services) { var dbContext = new FlightPlanDBContext(); dbContext.Database.Migrate(); services.AddCors(options => { options.AddPolicy(name: MyAllowSpecificOrigins, builder => { builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod(); }); }); services.AddEntityFrameworkSqlServer().AddDbContext <FlightPlanDBContext>(); services.AddControllersWithViews().AddNewtonsoftJson(x => x.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => { configuration.RootPath = "ClientApp/dist"; }); }
public ServersController(ILogger <FlightPlanController> logger, FlightPlanDBContext context) { _logger = logger; _context = context; }