Asp.net mvc consumes asp.net web api endpoint

Looking at this question:

Question SO

Darin Dimitrova's accepted answer looks attractive (.NET version 4.5). I'm just wondering how this compares performance with client-side solutions (e.g. using knockout / angular / jquery) to assemble HTML, given some JSON from the web-api endpoint. Someone has ever done some tests for this. What are the advantages and disadvantages of the “client solution” compared to the “server side razor” solution?

0
source share
1 answer

You should determine performance.

However, there is a very big difference between the two parameters:

  • if you do this on the client side (with ko / ng / jQuery), the server performs an API controller action and returns formatted data.
  • If you are doing this on the server side, in addition to executing the API action, the server must execute the MVC action, therefore, of course, the server does more work.

The only conclusion is that in the first case, the server has less work. And, as a rule, network traffic is reduced (a JSON object is usually easier than rendering a partial view).

If we are talking about user experience, in general, client-side technologies (jQuery, ko, ng) offer a much better user interface because the page is much more responsive: it is easy to show / hide elements, set focus, do trivial calculations, remote checks .. And if we use modern libraries, we can continue to work to improve interface compatibility. For example, breeze.js allows you to cache data on the client side to avoid additional ajax calls on the server, which gives a much more responsive experience, especially if you expect what kind of data you need and cache it before you start. You can even save data in HTML5 storage so that it is available for other sessions.

Then, from the user's point of view, I think this is a much better option. And the server has less work, which can make it even more relevant on sites with high traffic.

However, I do not know what is “more perfect” or even what “performs”.

Be that as it may, the use of technology on the client side is much better. But it takes some time to master related technologies.

+2
source

Source: https://habr.com/ru/post/1263357/


All Articles