Skip to content

Instantly share code, notes, and snippets.

@dileno
Last active September 13, 2019 20:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dileno/665d3027909c7a36f9c2cb76c352bab7 to your computer and use it in GitHub Desktop.
Save dileno/665d3027909c7a36f9c2cb76c352bab7 to your computer and use it in GitHub Desktop.
ConfigureServices method
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddDbContext<BlogPostsContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("BlogPostsContext")));
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy",
builder => builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader()
.AllowCredentials());
});
services.AddScoped(typeof(IDataRepository<>), typeof(DataRepository<>));
// In production, the Angular files will be served from this directory
//services.AddSpaStaticFiles(configuration =>
//{
// configuration.RootPath = "ClientApp/dist";
//});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment