using Microsoft.AspNet.Builder; using Microsoft.AspNet.Mvc; using Microsoft.Framework.DependencyInjection; namespace CorsMvc { public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.ConfigureCors(options => { // Define one or more CORS policies options.AddPolicy("AllowSpecificOrigin", builder => { builder.WithOrigins("http://example.com"); }); }); services.Configure(options => { options.Filters.Add(new CorsAuthorizationFilterFactory("AllowSpecificOrigin")); }); } public void Configure(IApplicationBuilder app) { app.UseMvc(); } } }