We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Putting header in DataManager


I m using an api service method to get the datasource for an ejGrid to do virtual scrolling

"getReportData() {
    this.gridData = new ej.DataManager({
      url: 'http://localhost:43317/api/WebReports/GetReportData/'+ this.reportId,
      adaptor: new ej.UrlAdaptor()
      ,crossDomain: true

" public IEnumerable<dynamic> GetReportData( int id, DataManager dm)
               return res;
and i m putting "[EnableCors(origins: "http://localhost:3000", headers: "*", methods: "*")]" above the controller to enable cors.

but this error appears

"XMLHttpRequest cannot load http://localhost:43317/api/WebReports/GetReportData/61. 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:3000' is therefore not allowed access. The response had HTTP status code 405."

i think the solution is putting a header at the request of the datamanager, but i don't know how.

Please advise.

6 Replies

KV Karthikeyan Viswanathan Syncfusion Team January 26, 2017 05:07 PM UTC

Hi Dina Abdelbary, 
Thanks for contacting Syncfusion support. 
We analyzed the code examples that you have shared. If you would like to fetch data from a custom action of controller, then we suggest you to use without localhost URL of the DataManager.  
Please refer to the below online documentation in which we have explained in detail on the various data binding concepts help link: https://help.syncfusion.com/js/datamanager/data-adaptors#url-adaptor  
We have prepared a grid sample with URL adaptor binding, which can be downloaded from the below location.  

Karthikeyan V. 

DA Dina Abdelbary January 29, 2017 10:27 AM UTC


The demo you have attached uses jquery not angular2 !! and also my question uses web api service, and the attached one uses a normal Controller not ApiController,
what do you mean about "use without localhost URL of the DataManager", so what if i wanna call a web api service method??
and also i asked about how to set the header at the request of the datamanager


PO Prince Oliver Syncfusion Team January 31, 2017 11:05 AM UTC

Hi Dina, 

Thanks for using Syncfusion products. 
We have created a new incident under your account. We suggest you to follow up the incident for further reference using your direct trac account.  
Please let us know if you have any concerns. 


MM Mayura Manahara February 21, 2023 05:19 AM UTC


I'm having this same issue,

is there any solution for this?

SS sathiyan senathirajah February 21, 2023 05:34 AM UTC


we were having this same issue , and trying to apply a fix for days now. 

using below line for get data

 this.data = new DataManager({

          url: ...some_Uri...,


         adaptor: new UrlAdaptor });

we wanted to pass the same Uri with the headers. 

thank you.

VB Vinitha Balasubramanian Syncfusion Team February 24, 2023 01:38 PM UTC


From your query, it seems that you want to pass custom headers. We have a detailed documentation regarding this topic. Please refer to the link below for more information.

Documentation: https://ej2.syncfusion.com/angular/documentation/data/how-to#adding-custom-headers

Live Chat Icon For mobile
Up arrow icon