Solution 1 :

First off, I would suggest using JSON over XML. There are two libraries you can use to serialize/deserialize JSON data: either Newtonsoft or System.Text.Json.

What would you recommend for sending data from .NET server to AJAX client? The POST method is the obvious alternative or there is a newest and best way of doing it?

You should definitely be doing this via a POST request.

Should I send the whole XML as a big unique chunk of data and parse it entirely in client or would be better to send it in array format (each item node as an array entry) and parse the array entries? My question here is what would be less CPU intensive for client, considering that machines are tablets and not PCs.

This really depends. If I were writing this I would add support for server-side pagination so that you know how many total records would be returned, but you’re only returning however many records are currently visible. This would dramatically improve speed.

Stream the data would be an option or this is a silly idea?

Just return a JSON response.

Solution 2 :

What would you recommend for sending data from .NET server to AJAX client? The POST method is the obvious alternative or there is a newest and best way of doing it?

There is no real difference between a GET and a POST, certainly not one that matters to your context anyway; GET would be fine.

A GET might look like this:

GET /api/parkinglot/1234 HTTP/1.1
Host: somehost.com

A POST might look like this:

GET /api/parkinglot HTTP/1.1
Host: somehost.com

{ "id":1234 }

It’s a text file, in essence, sent to the server. The server responds. It’s not something that is “the way we do things now” or “more modern”, POST doesn’t “perform better”.. It uses trivially more bytes, and is interpreted slightly differently by the server.. That’s about it. For what you’re describing, GET would be every bit as valid

Should I send the whole XML as a big unique chunk of data and parse it entirely in client or would be better to send it in array format (each item node as an array entry) and parse the array entries? My question here is what would be less CPU intensive for client, considering that machines are tablets and not PCs.

It doesn’t really matter. An array isn’t necessarily magically more or less of anything than XML; it’s all just text, interpreted by the client. You could write a really wasteful array based solution or a lean XML one. What you ought to be throwing away is the idea of sending massive blocks of data to the client. Clients are limited in resource; don’t send 2000 anything; what possible use could the user of the device have for 2000 items of data? You can’t show it on screen and meaningfully interpret it; if it’s a tabular block of data they’ll end up panning around it, scrolling, zooming, searching.. Think about redesigning the app so that it sends the data they need when they need it. You might consider that sending 2000 points of data to be rendered as 1000 pins on a map, lat and long, might be a great idea, the client might have a really good rendering engine that can cope with it and make it quick and a pleasure to use.. but really? It sounds like the server needs to do a lot more of the work here

Stream the data would be an option or this is a silly idea?

This is all streaming. Every download or upload is a stream of data. Data gets from A to B in a serial flow so that it pops out the other end the same order it went in. You need to mentally move away from the concept of streaming vs downloading vs sending vs whatever else you think of in terms of getting data around the place. These are not distinct things; start focusing on being really efficient with the data you request, the time it takes to process and emit from the server, and the processing that happens on the client. Decide where it’s best to do various calculations; there’s no point the client searching for all users called smith, the server sending a million people to the client and the client parsing and searching the data. The server should do most of that. If you want to draw a triangle on screen, you can send 3 points and have the client render it instead of having the server render a 2 million pixel image, sending it and having the client draw the image. In one of these examples the server does a lot, in the other the client does a lot. In both the problem is that there is an excess of data flowing. Focus on the strengths of each resource

I appreciate suggestions and examples!

It isn’t really what stackoverflow is for; we don’t design your programs for you or write them – you have to do that and we tell you how to fix issues you hit along the way. Questions that ask “what is the best” are typically off topic because they attract opinionated answers.

In writing this answer I haven’t really answered any of the questions you’ve asked in the way you want, because it simply isn’t permitted. Instead I’ve tried to keep to factual observations and points you should consider when forming your own solution. When you hit problems with that solution, we can help but “design and implement my solution for me” is not a problem

Problem :

Good morning!

I have this old Flash app (no worries the question is not about this!) which receives data from .NET server.

The data is a two thousand rows table and basically what I do is: query the DB with vb.net, create a long querystring with the data and send it back to Flash with a response.write method via GET. Then the Flash client parses it accordingly. The app is a parking lot GPS map that our employees uses to locate the vehicles. Believe it or not it has worked fine for the last 12 years and counting!

Long story short now my boss asked me to start over and remake entirely the app in HTML5. One major change is that for the sake of “standartization” the data will be converted from regular table columns to XML format so the chunk of data will grow in size.

Also I confess that I never feel completely happy on moving data back and forth via GET. I can’t remember exactly WHY I did it this dirty. Probably by the time we were in a rush to get the app running so it just worked and among a lot of other things to do it was put in the backburner and the rest is history.

Anyway, since we are restarting it fresh I’d like to do it the right way this time. So questions are:

  1. What would you recommend for sending data from .NET server to AJAX client? The POST method is the obvious alternative or there is a newest and best way of doing it?

  2. Should I send the whole XML as a big unique chunk of data and parse it entirely in client or would be better to send it in array format (each item node as an array entry) and parse the array entries? My question here is what would be less CPU intensive for client, considering that machines are tablets and not PCs.

  3. Stream the data would be an option or this is a silly idea?

I appreciate suggestions and examples!

Thanks!

By