Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Darren Eccles 59 posts 298 karma points
    Apr 20, 2016 @ 12:50
    Darren Eccles
    0

    Umbraco Web API - Cross Domain Problem

    Hi,

    I have a Umbraco 7 solution which is used to collect and send data using the 'UmbracoApiController' and works fine.

    I can use 'GET', and 'POST' to access my methods via jquery ajax on the same domain.

    However my problem arises when I try to access the API methods from a different domain (only with the 'POST' though, 'GET' works fine).

    If I had an mvc web api project, I could fix this problem by installing CORS through NuGet.

    My question is, how do I get around this problem with Umbraco 7? I want to be able to use the 'POST' method.

    Thanks

    Darren

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Apr 20, 2016 @ 16:34
    Alex Skrypnyk
    0

    Hi Darren,

    It's not Umbraco problem, making cross domain ajax POST request is the common problem.

    The best way to create some proxy on your server, and make requests via proxy method.

    Cheers

  • Darren Eccles 59 posts 298 karma points
    Apr 20, 2016 @ 16:54
    Darren Eccles
    0

    Hi Alex,

    Thanks for getting back to me, in the past I got around the cross domain issue by enabling cors in the project and this works perfect for 'POST' method.

    I just thought there may have been a simple solution in umbraco that you can enable this to work.

    The error I'm getting back in my browser is 'Response for preflight has invalid HTTP status code 405' when I try and hit the method. When you research this error, the solution seem to be enabling CORS. I tried install CORS, however it broke my solution because of the changes to the web.config file.

    Like I said in the first post though, the 'GET' works perfectly.

    I may have to add a web api project to my solution and reference the umbraco solution to access the methods I need.

    Thanks again Alex for getting back to me.

    Darren

Please Sign in or register to post replies

Write your reply to:

Draft