Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Cannot enable CORS ASP.NET 5

$
0
0

I'm making a web application with CORS enabled.
I've made 2 projects : Cors and CorsSource (https://github.com/redplane/Cors)

I've followed this tutorial

But, when I sent request from Cors to CorsSource with this ajax function:

$(document).ready(function(event){$.ajax({
            url: "http://localhost:65522/api/customer",
            method: "POST",
            crossDomain: true,
            headers:{
                ApiKey: "51aa964f-f1c2-4d36-b644-f53011bc5ebd","Access-Control-Allow-Origin": "http://localhost:65522/"
            },
            data:{
                Name: "Akai",
                Age: 20
            },
            sucess: function(data){
                console.log(data);
                alert("Ok");
            },
            error: function(jqXHR, textStatus, errorThrown ){
                console.log(textStatus);
                console.log(errorThrown);
            },
            complete: function(data){
                console.log("complete");
            }
        });
    });



I received this error : XMLHttpRequest cannot load http://localhost:65522/api/customer. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:12970' is therefore not allowed access.

Can anyone help me please ?
Thank you :)


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>