There seem to be two functionally different ways to enable cross-origin query sharing in Web API 2.
One of them is to import System.Web.Http.Cors , decorate the controller with the EnableCors attribute and write config.EnableCors() to WebApiConfig:
[EnableCors(origins: "http://111.111.111.111", headers: "*", methods: "*")] public class GenericController : ApiController {
Another is to modify Web.config :
<system.webServer> <httpProtocol> <customHeaders> <add name="Access-Control-Allow-Origin" value="http://111.111.111.111" /> <add name="Access-Control-Allow-Methods" value="*" /> <add name="Access-Control-Allow-Headers" value="*" />
Is there a difference between these two different approaches? Which one is right - isn't that the same? If both methods are used to enable CORS, will everything explode?
source share