0

XMLHttpRequest http://172.ip.ip.ip/employee/record/details cannot load http://172.ip.ip.ip/employee/record/edit/12345. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. The response had HTTP status code 500.

I tried the below solution which i found googling... - ['Access-Control-Allow-Origin'] = '*' is already defined on server still the same exception :(

Actually its part of an Angular POST Service sending data to server after modification in response to which server should return an object but i am getting Object [Error error] undefined

In chrome network Status - Status Code:500 Internal Server Error

Any advice, whether changes are required Client side or Server side ??

1 Answers1

0

I am answering it ..

Yes whenever we are getting above error(s) - server changes are required. Changes that resolved the issue :-

  1. If you are using MVC then -

Add

 HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");

in

 protected void Application_BeginRequest(object sender, EventArgs e)

{ }

  1. If you are using Apache,put this in/create a .htaccess file :-

     <FilesMatch "\.(ttf|otf|eot|woff|jpg|png|jpeg|gif|js|json|html|css)$">
          <IfModule mod_headers.c>
             Header set Access-Control-Allow-Origin "*"
         </IfModule>
    </FilesMatch>
    

You can add other extensions too..(y)