Xamarin C# data between server and client

935 views Asked by At

I recently started making a android app with c#(xamarin) and my goal was to send data to a database, I always got an error when connecting to the mysql server (server does not exist or connection refused).

Then I searched for a fix and realised that it was a bad idea to connect directly to the sql server.

My question is how do such simple "requests and responses" work?

And what is the best way to get data from a client to a database or server?

Sry if the question is makes no sense, until now I just worked with simple sql connections.

1

There are 1 answers

5
Danish On BEST ANSWER

The proper way to do it, would be to create an API layer that will talk to the database and your app would talk to the API I recently did an app on Xamarin and used the following to build the API:

  1. ASP.NET WEBAPI2 (for sending and accepting JSON data)
  2. Entity Framework 6.0 (for db modelling, reading writing)

to secure the API's I'm using basic http authentication over SSL (although it's not preferebly but secures it in a simple way)

for the xmarain app, you can potentially use something like restsharp portable to talk the REST based API