private void RegisterCors(MvcCorsConfiguration corsConfig) { corsConfig .ForResources("Values1.GetData") .ForOrigins("http://localhost") .AllowMethods("GET", "POST"); corsConfig .ForResources("Values2.GetData") .ForOrigins("http://localhost") .AllowMethods("GET", "POST") .AllowCookies() .AllowResponseHeaders("Foo"); corsConfig .ForResources("Values3.GetData") .ForOrigins("http://localhost") .AllowMethods("GET", "POST", "PUT") .AllowRequestHeaders("Content-Type"); corsConfig .ForResources("Values4.GetData") .ForOrigins("http://localhost") .AllowAllMethods() .AllowCookies() .AllowRequestHeaders("Content-Type", "Foo", "Authorization") .AllowResponseHeaders("Foo"); }
static MvcCorsConfiguration() { Configuration = new MvcCorsConfiguration() { ResourceNameIncludesActionName = true }; }
private void RegisterCors(MvcCorsConfiguration corsConfig) { var corsAttr = new EnableCorsAttribute("https://www.youtube.com", "*", "*"); corsConfig.AllowAll(); //強制回傳資料型態都為JSON //GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear(); }
private void RegisterCors(MvcCorsConfiguration corsConfig) { corsConfig .ForAllOrigins() .AllowAll(); }