Return HTML or JSON for a readonly table in ASP.Net MVC?
If you have a read-only table that will be updated via ajax, is it better to have the markup generated on the server or just return the JSON and render the table on the client?
They're both fairly simple to do, so I'm wondering which is preferable assuming the table markup is relatively simple.
At 1st I thought returning JSON might be faster, but I'm not sure. It seems like the bandwidth would be similar, and I don't know how fast ASP.Net can return a collection as JSON vs rendering a partial view.
Has anyone done any benchmarks or have any opinions on which they think is preferable in this scenario?
I think you should be returning JSON and allowing the consuming client to apply the rendering to that JSON, that way if your offering needs to change for different consumers, they just take the same raw data and apply the specific formatting rules they need.
If the nature of page is static then I would recommend server side rendering. If you want interactive experience then use client side rendering.
Here is a good link comparing Client-Side vs. Server-Side Rendering