CORS error when consuming ASP.NET Core 1.1 Web API from IONIC (Angular) app -


i have created asp.net core 1.1 web api consumed angular2 (ionic) app. @ beginning of project, getting cors errors, which, after modifications web api, able resolve. morning updated our live web api changes made on past week , reason or other, getting cors error again (when angular app consumes live web api - works fine connect web api running on localhost pc on lan). error is:

xmlhttprequest cannot load http://inspections.propworx.co.za/api/inspections. response preflight request doesn't pass access control check: no 'access-control-allow-origin' header present on requested resource. origin 'http://192.168.1.100:8100' therefore not allowed access.

i have following in web api startup.cs:

public void configureservices(iservicecollection services) {     services.addcors(options =>     {         options.addpolicy("sitecorspolicy",         builder => builder.allowanyorigin()         .allowanymethod()         .allowanyheader()         .allowcredentials());     });     ... } 

and this:

public void configure(iapplicationbuilder app, ihostingenvironment env, iloggerfactory loggerfactory) {     app.usecors("sitecorspolicy");     ... } 

in both cases, before services.addmvc() , app.usemvc respectively. still doesn't work. have tried adding

services.configure<mvcoptions>(options => {     options.filters.add(new corsauthorizationfilterfactory("sitecorspolicy")); }); 

in configureservices, after services.addcors, no avail. have tried adding:

[enablecors("sitecorspolicy")] 

to top of controllers, didn't help.

this working, , don't know couldve done it's not working :/ ideas anyone? thanks...

there problem there no web.config file... asp.net core doesnt seem generate 1 web api's, needed cors...


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -