CORS error even after adding Allow-control-allow-origin plugin

Hi everybody, I have a problem with CORS during executing ionic serve. In my app I try to access a simple test .Net WebService method that returs a stirng array and I encounter allow access error. I have added Allow-Control-Allow-Origin plugin to my Chrome Canary browser that is recommended in “http://blog.ionic.io/handling-cors-issues-in-ionic” as a simple solution only for testing app in browser and the error still .
Can everyone help me to solve this issue that I think, it’s seems to be negligible, but waste my time for few days!!!
thanks in advanced

Cors has to be enabled on the server side. i.e your .NET code. Otherwise it will not work.

Install Thinktecture NUGET package.
In your global.asa add this
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AppFeatures.InitializeFromWebConfig();
//This opens up cross site scripting. So after your proof of concept, you might want to tighten the security here
MvcCorsConfiguration.Configuration.AllowAll();
}

1 Like

Thank you nishantpant for your reply. As I understand from your message, when I want to access any .NET webservice, must use NUGET package, right? and if yes it seems that I must use Visual Studio 2013 (at least and recommend 2015+), because thinktecture NUGET is an extension package for VS2013 or later. Therefore I can not access to a webservice that is not own or developed with VS2010 for example and I can not add this property (CORS free), right?

Hi everyone,

I am new to ionic2 and Angular2. I am also facing CORS error message in my ionic 2 app.

My backend code is in PHP Zend framework, I have created a service file to establish the connection backend code.

I have included the header as Allow-control-allow-origin: ‘*’ part in PHP page. But still facing issue.

When I test MyApp on Ionic-View app nothing is returning.

Hi AkashM08 , take a look at bellow link:

I had also this problem and it was solved. good luck