'How to restrict other domains calling web api, means i want to allow only one particular domain to call web api

I'm doing one project in Web Api, I want to restrict other domains calling my web api, but only allow my domain name only. How can I restrict that, I'm waiting for your valuable answers

I added this code inside WebApiConfig

config.EnableCors();

and the following code on top of the controller

[EnableCors(origins: "http://localhost:49873", headers: "accept,content-type,origin,x-my-header", methods: "*")]


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source