CORS: What is it?

Definition
Cross-Origin Resource Sharing (CORS) is a technique for relaxing the same-origin policy, allowing Javascript on a web page to consume a REST API served from different origin.

For example, the API is hosted in domain-a.com, but we have another system in another domain, domain-b.com. To enable it to be used in another domain, you need to enable CORS.

How to use it in C#/ASP.NET?
All you need to do is add using directive before the namespace and add EnableCors after the namespace. Below code will enable all domain to use it. :)

using System;
...
using System.Web.Http.Cors; 

namespace LianaAli.Api.Controllers 
{
    [EnableCors(origins: "*", headers: "*", methods: "*")] 
    public class DemoMainController : ApiController 
    {
        ...
    }
} 


References:
1. Understanding CORS