Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a project that runs on Umbraco 7.1.1 and I want to post an object to a webapi in the project.
The action is located on /umbraco/api/dummyapi/getsearchcontent with the following code
public dynamic GetSearchCount(Guid token, SearchCountRequest request)
// here I do some code
But when I post my object from Angular I get "XMLHttpRequest cannot load *. Invalid HTTP status code 405". The Angular code isn't in the same project.
Search results on Google tell me that this is an issue with CORS so I have tried different things like:
I have found that installing this package: https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Cors should be a solution but it isn't possible because Umbraco uses Microsoft.AspNet.WebApi Version 4.. and this isn't compatible with the earliest version of Microsoft.AspNet.WebApi.Cors.
Any suggestions on how you got CORS working?
Am I missing something or?
I have the same issue, did you solve it ?
No I did not solve it but I worked around it.
I placed the Angular code in the same project so it runs on the same localhost. Now the API and Angular are running on the same host so there are no longer CORS isssues
I my case
I solve it it in 2 step, add in web.config
<remove name="X-Powered-By" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Request-Headers" value="*" />
Other problem is avoid send authorization header in angular request
Thanks Yakov Lebski for the solution.
It works for me for simple ajax post.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted