Error loading json

I get stuck with my first Web Core test. I am trying to load a simple JSON (url = in a WebDbGrid.
WebClientConnection.URL := url;
Connecting a WebClientDataset to the WebClientConnection leads to an error (Error connecting to URI

Something wrong with the json?


When I put the compiled code on my production server and keep getpredictors.aspx as uri then the app works fine. That it doesn't work on my development machine has to do with CORS ( Cross-Origin Resource Sharing).
However the DBGrid sample (cars) that comes with TMS Web Cor doesn't have that problem. Probably solved on the TMS server?!.

Works fine doing exactly what you described in your report. However, when you start the application and look at the web console you get the error message that the CORS policy of your server is not allowing access:

Access to fetch at '' from origin 'http://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

The WebClientConnection has a Headers property where you can set you header as required by your server.



Thanks Holger.
So I need to enable CORS on the webserver.

... or provide the header that your server uses to authenticate the request. I do not know what is used on that side. The error message states that the header sent is not as required by the server.

I am not a hard core developer so I need more time to find out how to deal with CORS on my ASP.NET server.
But here is a working sample that I posted on my server to avoid the CORS problem which shows that rows in the first fixed column are not in sync with the other rows in case there is a cell with a very long string.

I'd try adding Access-Control-Allow-Origin to the Headers property with the value no-cors. If that works no changes to the server are necessary and you would do exactly what Microsoft suggests in the error message.

So I added the following in the headers property of the WebClientConnection control.

but without succes.

Check in the Network tab what your request looks like and verify that the header does indeed contain the info.

Hm, don't show too much.

You need to select the request in order to browse header and response.

This is what I see Holger. But maybe I should ask a colleague who is knowledgable when it comes to these kind of techniques.

You need to select the request from the app to the service. You are looking at the request of the web page right now.

Excellent. As you can see, the header is built correctly on the client and the server indeed is not using the value. The fix has to be done on the ASP.NET side.

As I have used ASP.NET myself, allow me a personal question/suggestion: May be providing the information from the database can be done using XData to use even more of the advantages/features of TMS Web Core. Of course, I don’t know what licenses you habe available or if the backend is developed by another developer/company. Again, the current service can be used fine if you can fix the authentication issues.

Thanks for your patience Holger.
And I am aware of XData, but for now I only need to grab readonly datasets from the server. And as I already have the ASP.NET applications there is no need for an additional piece of software.

It also should be a simple fix on the ASP.NET server as well. I have developed my fair share of .NET applications as well and a setting in "some" XML config file will certainly help ;-)

You can find info on these settings here for ASP.NET: