Sachin Singh

Sachin Singh

  • 7
  • 55.8k
  • 82.1k

EnableCors attribute is not working after hosting on IIS .

Aug 17 2020 12:07 AM
Cors is enabled in the web api at global level and is working fine locally, i am able to call it from any origin
but after hosting it on IIS 7.5 for testing , the cors policy again started poping up.
  1. public static void Register(HttpConfiguration config)  
  2.        {  
  3.            // Web API configuration and services  
  4.   
  5.            // Web API routes  
  6.            config.MapHttpAttributeRoutes();  
  7.            EnableCorsAttribute cors = new EnableCorsAttribute("*""*""*");  
  8.            config.EnableCors(cors);  
  9.            config.Routes.MapHttpRoute(  
  10.                name: "DefaultApi",  
  11.                routeTemplate: "api/{controller}/{id}",  
  12.                defaults: new { id = RouteParameter.Optional }  
  13.            );  
  14.             
  15.        } 
 Does it need https to work?
 

Answers (1)