2
I have a Web API where I restrict access to your methods through the EnableCors
, indicating the URL I want to give permission, as follows:
namespace WebService.Controllers
{
[EnableCors(origins: "http://myapp.net", headers: "*", methods: "*")]
public HttpResponseMessage GetItem(int id) { ... }
}
That way, if I try to access my controller of an application other than the url "http://myapp.net" the lock happens as expected.
However, when I try to access the direct api, just pasting and accessing in the browser the url of my "www.minhaapi.com. /Getitem/2", blocking does not happen.
I would like to know how best to allow access to my domain-only api x?
What would be this "block" to avoid copy-and-paste? In my view, it’s all right. That’s how CORS behaves.
– Leonel Sanches da Silva