In my web application I need to get data from Wikidata, for example to show item's details. I thought about using ajax for this, but was't sure from where I should to call it, so I asked this question.

But after some thinking, why should I use ajax? I can make http request from my server side code (C#). I can put it into controller, get information from Wikidata, fill out ViewModel and then call View(ViewModel).

What can be some downsides of this? Will it affect performance?

So, question is: ajax or C#?

UPDATE: Before development starting I was thinking if I should develop client part (HTML, JavaScript) and Web API separately. In this case I would use Ajax of course. But I decided at this stage I'll do one MVC application. Because it has server side code anyway (even in View), so I think that http request from C# looks more naturally than JavaScript request.

  • 2
    So instead of using a well-known, well-understood API to get your data, you want to scrape a web page? Commented Jan 11, 2017 at 20:15
  • @Robert_Harvey, no, why scraping? I use the same API, actually SPARQL query, I can just call it from ajax or from C#.
    – Alexan
    Commented Jan 11, 2017 at 20:19
  • 2
    Actually, you would call it from Javascript or C#. AJAX is a technique. So you're calling an XML web service from either C# or Javascript. Which one you choose depends on what your requirements are. If you need the data to go directly to the browser, you use Javascript. If you want the data to go to the server first, to be inserted into the web page via ASP.NET MVC, you would use C#. Commented Jan 11, 2017 at 20:21
  • of course it's JavaScript, just use jQuery and Ajax
    – Alexan
    Commented Jan 11, 2017 at 20:23
  • 1
    Yes. So figure out if you want the data to come directly to the browser and bind it to some DOM elements via some mechanism like Knockout or just plain Javascript, or if you want it to go directly to the server and insert it into your View there. Commented Jan 11, 2017 at 20:24

1 Answer 1


Usually the overriding reason for making a 3rd party API call server side is that it requires you to have an account, username and password with the 3rd party.

If you make the call client side then you expose this information to the user of your website/app

There are other reasons to consider, perhaps you merge the api data with some other data you only have serverside, perhaps you have more than one provider for the same data and want to switch between them but still provide the same datamodel to your client etc. perhaps javascript just isn't good enough to run your business logic

But, these are more meta-programming concerns about ease of maintainability etc. given the cost of a server side call and the extra step in the network traffic, if you can push it to the client it is usually a good thing to do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.