0

I want to send the data to back-end for creating the details about customers using http post method with API URL. But it refused to connect the back-end. because it need some permission for access the post method. please give some guide line and resolve this error.

i already do some changes in app.setting for Allow-permission-* in back-end side. but nothing happend.

    //This is my ts code

    this.http.post('http://localhost:2401/api/CustomerAPI', 
    jstring).map(res => res.json()).subscribe(data => {
    console.log(data)
  }, (err) => {
    console.log(err)
  });
}

Access to XMLHttpRequest at 'http://localhost:2401/api/CustomerAPI' from origin 'http://localhost:8100' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Then it also show Failed to load resource: net::ERR_CONNECTION_REFUSED

  • could you CustomerAPI post code – kunal verma Aug 01 '19 at 04:54
  • var jstring = JSON.stringify({ CodeId: this.Code, customerNameId: this.CustomerName, ProjectnameId: this.Projectname, SortcodeId: this.Sortcode, contactId: this.contact, AddressId: this.Address, Address2Id: this.Address2, CountryId: this.Country, PostalcodeId: this.Postalcode, PhoneId: this.Phone, FaxId: this.Fax, CheckeboxId: this.Checkebox, DescriptionId: this.Description –  Aug 01 '19 at 07:25
  • I want to do some access permission in my Back-end at "appsettings.json" –  Aug 01 '19 at 07:27

1 Answers1

0

You are having CORS issue, Read this CORS in .NET Also, a solution is this .NET CORS solution

Zadat Olayinka
  • 441
  • 3
  • 8
  • I already red that i'm new to .net so i can't understand. What they are explained there???? can u please help me by any other way? –  Aug 01 '19 at 08:47
  • you need to configure your server to allow headers, methods, origins so your client-side app (ionic App) can send requests to your server and get a response. Click on this link and do exactly what they listed out there [Solution] (https://stackoverflow.com/a/45844400/6800815) – Zadat Olayinka Aug 01 '19 at 08:56
  • wow thanks a lot for your reference.... That was clearly explained there. –  Aug 01 '19 at 11:31
  • how do i do that? because i'm new to here! –  Aug 02 '19 at 09:01
  • find more information [here] (https://meta.stackexchange.com/questions/173399/how-to-upvote-on-stack-overflow) – Zadat Olayinka Aug 02 '19 at 09:08