Created
February 8, 2020 03:54
-
-
Save joaobibiano/e8b5a61fa0192b000f27fef4cddc47a6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins"; | |
public IConfiguration Configuration { get; } | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
services.AddControllersWithViews(); | |
services.AddDbContext<ContextIM>(options => options.UseSqlServer(ContextIM.GetConnectionString())); | |
services.AddCors(options => | |
{ | |
options.AddPolicy(MyAllowSpecificOrigins, | |
builder => | |
{ | |
builder | |
.AllowAnyOrigin() | |
.AllowAnyHeader() | |
.AllowAnyMethod(); | |
}); | |
}); | |
} | |
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) | |
{ | |
app.UseHttpsRedirection(); | |
app.UseStaticFiles(); | |
app.UseRouting(); | |
app.UseAuthorization(); | |
app.UseCors(MyAllowSpecificOrigins); | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapControllerRoute( | |
name: "default", | |
pattern: "{controller=Site}/{action=Index}/{id?}"); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment