ASP.NET Core & Xamarin meetup: Gotta app ‘em all

Roeland Techniek

On October 18th Infi was host to another meetup, this time titled “ASP.NET Core & Xamarin: Gotta app ‘em all”.

The theme of the meetup was Pokémon, and the goal was explaining how to use .NET to implement a basic API on top of ASP.NET Core to serve a Pokémon App built with Xamarin. This meetup was organised by the Dutch .NET Group.

How to implement the API using ASP.NET Core

After having a bite of some pizza’s sponsored by Infi and Subway lunchboxes sponsored by Microsoft, Fanie Reynders kicked the meetup off by showing how to implement the API using ASP.NET Core. The general flow of his presentation can be followed on Github.com/faniereynders where each newer “release” tag (or “step”) represents an incremental improvement over the previous “release”. In this way he showed how to start off simple and gradually build a proper API, each time highlighting specific improvements over the previous step. He did this while using VS Code, showing that VS Code is becoming a mature IDE for .NET development. Fanie put specific emphasis on securing your API using JSON Web Tokens (more information about JWT). He also showed that ASP.NET Core is a lot more flexible in the way you specify your application configuration. Apparently even .INI-files are back from the dead and can be used for this purpose, next to environment variables, .json-files and the old Web.config, amongst others.

Managing secrets

Of particular interest was the use of the Microsoft.Extensions.SecretManager.Tools NuGet package for managing secrets from the commandline (check related GitHub page). These secrets (for example an API-key or a database password) are generally something you don’t want to commit into e.g. Git, but the application does need them when checked out. Microsoft.Extensions.SecretManager.Tools helps by allowing you to store your secrets on your local machine (presumably under your user account), and by integrating seamlessly into the ASP.NET Core application configuration infrastructure.

Fanie concluded his part of the evening with a nice example of how to use an outputformatter to return data to a client depending on the Content-Type specified in the request, and by mentioning a handy library called AngleSharp for parsing HTML and using CSS query selectors which he used for retrieving data from a Pokémon Pokedex.

How to implement a basic Xamarin app

After a break (of course with some beers), Gerald Versluis picked it up and showed how to implement a basic Xamarin app that consumed the API built by Fanie. Gerald took the same approach as Fanie, having several “releases” ready in a Git repo and taking us through the steps he took to implement the eventual app. He explained how to use Refit to access the API using JSON Web Tokens, and FreshMvvm to implement MVVM on top of Xamarin Forms. Some other notable NuGet packages mentioned by Gerald: FFImageLoading for easily loading, caching and transforming images from XAML, Humanizer for displaying time related data in a more friendly manner (for example “5 hours ago”, “Yesterday”), and PropertyChanged.Fody for more easily managing changes in models. He ended his part by doing some live coding, which is always dangerous in front of an audience, but he pulled it off, implementing a POST request behind a button in the app to store some data using the API.

Check the recordings!

Of interest to those that could not attend the meetup: it was recorded and streamed live by sdncast.nl, so the recording of the meetup will probably be online soon on their website. And the recording can already be found on YouTube: part 1 and part 2.

All in all a great evening with interesting technical topics! Hope to see you next time!

[Roeland is developer at Infi.]

Een afspraak maken bij ons op kantoor of wil je even iemand spreken? Stuur ons een mail of geef een belletje.