c# - Call from Angular to webAPI on different domain is turned into OPTIONS -


i using asp.net webapi angular. when make call angular method on webapi, error in chrome (it working fine in ie), , can see fiddler call made "options" (i using $http.post , $http.get), in ie made post or get.

i have tried config header send request ('content-type': 'text/plain'), , working fine in chrome. problem using authorization in header, , when add authorization in header, hack content-type isn't working anymore.

i have tried add nuget packages "cors" webapi (and enabled in controller [enablecors("", "", "*")]), has not made changes.

is there having solution problem?

thanks in advance :-)

do add code in global.asax's application_start method when use cors? not add enablecorsattributeon action

globalconfiguration.configuration.enablecors(); 

or don't need use cors lib,it used when add children node in web.config's node system.webserver

<httpprotocol>       <customheaders>         <add name="access-control-allow-origin" value="*" />         <add name="access-control-allow-headers" value="*" />         <add name="access-control-allow-methods" value="get, post, put, delete" />       </customheaders>     </httpprotocol> 

Comments

Popular posts from this blog

android - Pass an Serializable object in AIDL -

How to provide Authorization & Authentication using Asp.net, C#? -

How to use Authorization & Authentication in Asp.net, C#? -