Im writing a little service using c#(.net framework) and odata V4. My clientside is AngularJs. On my localhost everythink works fine, but when Im releasing my code to the server(widows server 2012 R2) I got cors problems. I tried different solutions:
Tried to put
Access-Control-Allow-Origin,Access-Control-Allow-Headers,Access-Control-Allow-Methods,Access-Control-Allow-Credentials
at web.config, got401
and500
response preflight.add
CorsHandler
class to handle the preflight/addApplication_BeginRequest
to handle it as well, no luck (return there the Access-Control-Allow-Origin and etc...). and stuff from here as well: Handling CORS Preflight requests to ASP.NET MVC actions
and finally tried the Microsoft.AspNet.WebApi.Cors package just like that:
var cors = new EnableCorsAttribute("cool.mydomain", "*", "*");
config.EnableCors(cors);
And guess what, its no helping either!
When I send the POST
method I have to send it with Content-Type:"x-www-form-urlencoded"
, because application/json
triggers the preflight, and text/plain
is not supported for some reason.I have an enpoint which use ODataActionParameters
object, and its always null,assuming because of the content type of the urlencoded.
Hope Someone can help me, Im banging my head...