Click here to Skip to main content
15,886,830 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone,

what is the difference for below web api calls.

1. Make a web api call through MVC controller to get the data from database.
ClientScript -> MVC controller method -> Web Api controller.
It returns data respectively and will be render in page.

2. Make a web api call through Ajax.request to get the data from database.
ClientScript -> Web Api controller
It returns data and will be render in page.

Which one is good in terms of performance basis.

Thanks.

What I have tried:

I have googled ,but couldn't get clear answer.
Posted
Updated 30-Sep-16 6:19am
Comments
[no name] 30-Sep-16 11:38am    
"Which one is good in terms of performance basis.", whichever one that you have tried and the one that meets your performance requirements.
King Fisher 30-Sep-16 11:51am    
I have tried the both , but i m looking for the difference.

1 solution

So what i think you are doing is calling a web api action from an mvc controller vrs a direct call client side to web api.

First thing to note, web api and mvc are basically the same thing. So much so that in .net core they share the same base class.

In terms of performance, since they are essentially the same, based on your stated process you are probably going to want to make calls directly to your web api end point vrs your mvc endpoint that calls your web api...soley for the reason that you don't make a second request.

If i did not understand you correctly and you call MVC and Web API in the same manner (only javascript)...then performance is more than likely the same.

But really, you should just take something like fiddler, monitor your traffic and see what works best for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900