Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

friends I am new to Asp.net WebApi, I was trying to send a post request to generate a token from my Google Chrome and it gives me this error.

Access to XMLHttpRequest at 'http://localhost:7068/token' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I can send a post request to controllers since I have enabled cors in WebApiConfig.cs here is the code I used to enable cors

EnableCorsAttribute cors = new EnableCorsAttribute("*", "*", "*"); config.EnableCors(cors);

my problem is I cannot generate a token from the WebApi it gives me the above-mentioned error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...