AngularJS + ASP.NET Web API Cross-Domain Issue

前端 未结 4 1862
我在风中等你
我在风中等你 2020-12-13 21:49

Moving forward with my mobile app development learning process, I\'ve found a new obstacle: Cross-origin Request Sharing or CORS.

I am using a combination of Angular

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 22:32

    Check out Thinktecture Cors objects, with those (nugettable) you can get full CORS support in WebApi without any code of your own.

    Even with a correct CORS implementation I've had a really strange issue with IIS 7 that was solved by enabling all verbs for WebDav (yes, WebDav - don't ask me why I just followed instructions on a blog post :-D).

    Do this:

    • Open IIS manager, go to your application's Handler Mapping.
    • Double click the WebDav handler
    • Click "Request Restriction"
    • On the "Verbs" tab, select "All verbs".

    Again, no idea why WebApi uses WebDav, but this solved problems with POST and DELETE that wouldn't work in spite of a correct CORS implementation.

提交回复
热议问题