JSON response in ASPX


Denis Depauli

Hi, I need to transfer some data from a aspx website to an app. I believe the best way is to use a webapi with custom methods and send/receive data i JSON format. I've read and tryied the GetJson sample and, of course works fine.

The big problem (for me) is to replicate the data sending in aspx (I've tryied) with this code

But HTTP component fails to receive data with no error (ErrorThrown property is blank/null). I'm totally unable to understand what I've missed (of course I must use iis+aspx, php is not ann acceptable solution) .

Any idea?


DecSoft

Hello Denis,

Unfortunately I have no experience with ISS nor ASPX (I touch a bit of C# in the past however), but, I will try to help you. My bet is that what fail here is the lack of CORS permissions. The behaviour of the HTTP control that you describes probably means that CORS are not well configured in the server side, and, you must do it in order to properly communicate your app with the server.

Please, take a look at this website: https://enable-cors.org/server.html, or, anyway, try to search how to configure the CORS permissions in ISS / ASPX, because I think this is what must be done: I am not sure if you can do it in the same ASPX script (by some properties of methods of the "Response" object), or if you must configure the server in another way, directly touching the server's configuration. For example, in PHP we can do that: configure a script in order to set the CORS permissions, so we no need to touch the configuration of the server (Apache, etc.). Probably it's possible to do it also in an ASPX script.



Denis Depauli

Thanks works FINE!

For other people who may have the same problem..

I've installed MS CORS 1.0 and added this lines to web.config


DecSoft

Hello Denis,

Glad to know that you got it. Certainly, must be different ways to enable the CORS permission in every server / language. Using the server's configuration, using the language "response" itself, and maybe more... Thanks for share one of them with us!


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.