C# – How to store data for Windows Store apps

cmetrowindows

I have a application which requires me to save data to a database not located on the users computer. Which approach is the best to save and access data for this scenario? Normally I would use Entity Framework and MS Sql Server but this seems not to a options for me with windows store apps.

Best Answer

I think using some kind of web-API proxy would be your best guess if you are concerned about the security of the app.

It has been proven that Windows 8 apps can be decompiled easily when they are not obfuscated (just like any other Java or .NET based program without obfuscation), and even with obfuscation, one could argue that an eventual hacker would be able to find your connection string anyway.

You can have a server-side web-application language such as PHP, ASP .NET or ASP .NET MVC handle the input from your app, and then make that web application post its data further to the SQL server.

For reading data, the app could pass some ID along with the request in the URL, and the web application could then fetch the information needed from the SQL server, and write the data in the response for your app to read.

This could all work just like a RESTful API, or something similar.

Here's a short example.

  1. The app requests the URI http://www.example.com/api/get-customer?id=38, assuming that you own the domain example.com, and that this is where you host your server-side web-application.
  2. The website internally connects to the database, fetches all information regarding the customer with ID 38, and writes it to the HTTP response through a deserializable format (JSON or XML would do).
  3. The app gets the response, parses it, and uses it visually in the GUI.

This is for fetching data though, but I am sure it demonstrates the concept. You can use it to insert data as well, and so forth.

I realize that a solution like this requires a server or some form of hosting, but at least it helps you move on.

Related Topic