using Microsoft.AspNet.Builder; using Microsoft.AspNet.Hosting; using Microsoft.AspNet.Mvc; using Microsoft.AspNet.Mvc.Cors; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; namespace CorsMvc { public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddCors(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, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.UseMvc(); } } }