Reputation: 13
What is the best way / fastest way to use minimum resources while sending data back to the server. For example I have a table on the View and I am looping through it via IList
In the controller / repository I am filling the IList, and during this time I am creating a new object and adding this object in the IList. (Does creating each object too much memory?)
Is this the right way to do things and fastest using least resource or I should use JSON to return the data to the View
Upvotes: 0
Views: 386
Reputation: 16038
Json is not for pushing data to the view but to the client. The connection between Controller and View happens on the server side - so it does not matter much (in terms of performance/datasize) what kind of datatype you use to send data to your view. Than the view gets rendered to html on the server and the resulting html is sent to the client.
And here is the point where datasize matters. When you have a large table you want ot display the generated html is much bigger than the pure data you need to create the table.
So you might consider to use ajax and request just the data from your controller which responds with a Json object. The client will receive the data in a javascript callback and construct the html table (jQuery template is a good toolkit for this).
Upvotes: 1