aas
aas

Reputation: 197

C# web api request allow only for listed domains

I have web api hosted on api.domain.com and my app is in app1.domain.com and app2.domain.com

I want to allow api.domain.com should be accessed only from app1.domain.com and app2.domain.com

how to achieve this? I have tried with allow access control but i don't want to show the allowed domain's in browser cosole

and also when i access api.domain.com through browser should show 403 - Forbidden: Access is denied.

Please help

Upvotes: 0

Views: 4764

Answers (2)

Pankaj Kapare
Pankaj Kapare

Reputation: 7812

You can use IP and Domain restrictions features of IIS. This feature needs to be installed explicitly.

enter image description here

Upvotes: 0

Bret Lipscomb
Bret Lipscomb

Reputation: 499

More specifically to my comment above. You have to enable CORS support for the api endpoint controller.

  • Add CORS to the VS project
  • Then use the [EnableCors(origins: "https://app1.domain.com,https://app2.domain.com")] attribute on the controller.

Upvotes: 1

Related Questions