Skip to content

Instantly share code, notes, and snippets.

@ericlw
Last active May 12, 2016 00:47
Show Gist options
  • Save ericlw/98d36751055e1df64cd8dab0fb32dff9 to your computer and use it in GitHub Desktop.
Save ericlw/98d36751055e1df64cd8dab0fb32dff9 to your computer and use it in GitHub Desktop.
Tutorial: Build a Mobile App with an ASP.NET backend

#Tutorial: Build a Mobile App with an ASP.NET backend

Determined to make a network aware mobile app and trying to decide on a backend stack to use? If you come from a background of using ASP.NET or are interested ASP.NET's performance benefits in your server stack, learn how to quickly get up and running using ASP.NET for your mobile backend in 15 minutes! This tutorial will show you how to build your first REST API using ASP.NET and connect it to an iOS or Android app!

The ASP.NET framework runs on multiple platforms, written in C# which is a powerful and expressive language. It is used in enterprise applications and comes with great tooling support, IDEs and a robust community.

Despite the benefits of that one framework, incorporating authentication can be counterintuitive. You want to protect data and doing it securely isn't always obvious. Stormpath integration helps easily add authentication to your apps, and this article will dive into how to do it well.

##Overview of Example Project

Stormpath Notes is a note taking application that stores user generated notes online within Stormpath. We will be building the backend to power it. Afterwards you will be able to leverage this information to make large scalable applications comparable to other popular note taking apps!

We have a separate tutorial for how to build the iOS and Android apps that can use this backend, so check them out once you've finished this tutorial.

There will be two endpoints that you'll construct by the end of this tutorial:

'GET /notes' - returns the notes for the authenticated user in the form of a JSON object.

'POST /notes' - takes a JSON object with the notes and saves it for the authenticated user.

##Preparing Dev Environment

There are a few steps we need to take to make sure our local server works with Android emulators and your test devices.

Within your .net folder, creating a file called hosting.json and add the following lines

{ "server.urls": "http://*:5000" }

//to make your json keys lower case, add this line to your ConfigureServices method in the Startup class services.AddMvc(options => { options.InputFormatters.Clear(); var jsonOutputFormatter = new JsonOutputFormatter(); jsonOutputFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); jsonOutputFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Ignore; options.OutputFormatters.Insert(0, jsonOutputFormatter); });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment