The requested resource does not support http method 'OPTIONS'.?

前端 未结 6 1287
青春惊慌失措
青春惊慌失措 2020-12-06 01:43

I am making the following request to an asp.net web api PUT method from my angular.js client:

var org = {
                  OrgId: 111,
                  nam         


        
6条回答
  •  感情败类
    2020-12-06 01:58

    This is almost certainly a CORS problem. I'd first read up about it to make sure you understand what this is and why it is important. And I would guess that your server configuration is not correct.

    Unfortunately, I don't know much about .net, but this CORS tutorial for .net describes what you should do quite clearly.

    It looks like you are missing an EnableCors annotation. It looks like you need to add something like [EnableCors("*", "*", "*")] to your controller. Explicit handling of OPTIONS is not necessary. Of course, in producition, you don't want to use wildcards for your CORS handling. They should be more specific, but this is fine for testing.

提交回复
热议问题