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
Hi community
I have controllers that work fine crossdomain when doing a GET. I used the following setting in web.config:
<customHeaders> <add name="Access-Control-Allow-Origin" value="*" /></customHeaders>
However, I can't seem to do a crossdomain POST the same way. When executing the POST, I get following two errors (I am a bit unsure as to whether #1 is an actual error):
1) OPTIONS [some url here] [some controller method here] @ [someplace in POSTing js file].
2) (index):1 XMLHttpRequest cannot load [some url here]. Invalid HTTP status code 405
I tried installing the Microsoft.AspNet.WebApi.Cors NuGet package, but it doesn't seem compatible with my Umbraco 7.
How does everyone else here handle CORS POST requests?
Hi,
Did you try config like that:
<httpProtocol> <customHeaders> <remove name="X-Powered-By" /> <add name="Access-Control-Allow-Origin" value="*" /> <add name="Access-Control-Request-Headers" value="*" /> </customHeaders> </httpProtocol>
Other problem to avoid authorization header in angular request.
Thanks, Alex
Thanks Alex - I tried that already, no luck.
Maybe this piece of code can help ?
https://github.com/noshitsherlock/umbraco-angular
using System.Web.Http.Filters;
namespace UmbracoTest.Services { public class AllowCrossSiteJsonAttribute : ActionFilterAttribute { public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) { if (actionExecutedContext.Response != null) { if(actionExecutedContext.Response.RequestMessage.RequestUri.Host.ToLower() == "localhost") actionExecutedContext.Response.Headers.Add("Access-Control-Allow-Origin", "*"); } base.OnActionExecuted(actionExecutedContext); } } }
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/63841-Web-API-2-and-cross-origin-resource-sharing-CORS
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Enabling ajax POST with CORS through a UmbracoApiController
Hi community
I have controllers that work fine crossdomain when doing a GET. I used the following setting in web.config:
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
However, I can't seem to do a crossdomain POST the same way. When executing the POST, I get following two errors (I am a bit unsure as to whether #1 is an actual error):
1) OPTIONS [some url here] [some controller method here] @ [someplace in POSTing js file].
2) (index):1 XMLHttpRequest cannot load [some url here]. Invalid HTTP status code 405
I tried installing the Microsoft.AspNet.WebApi.Cors NuGet package, but it doesn't seem compatible with my Umbraco 7.
How does everyone else here handle CORS POST requests?
Hi,
Did you try config like that:
Other problem to avoid authorization header in angular request.
Thanks, Alex
Thanks Alex - I tried that already, no luck.
Maybe this piece of code can help ?
https://github.com/noshitsherlock/umbraco-angular
using System.Web.Http.Filters;
https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/63841-Web-API-2-and-cross-origin-resource-sharing-CORS
is working on a reply...