I recently had to generate a JSON Web Token (JWT) as a response from an login request to an api. The idea is to POST the user’s credentials from a mobile app, and to respond with a JWT. The mobile app can then verify that the user has logged in correctly. A quick introduction to JWT But let’s step out for a moment. What is a JWT exactly? According to jwt.io, a JSON Web Token is an open, industry standard

Continuing on my previous post on WebAPI, Autofac and filters, I now want to add an integration test. Unit testing WebAPI controllers is no different than testing other pieces of code. Just inject mocks in the constructor and you’re good to go. Integration testing can be as simple, if you’re not using filters. The filters can, however, add interesting behavior to your controllers, like the exception handling I explained in my previous post. To fully test this, you will have

A short post with a small, useful tip. It’s mainly for my future self, but may be good to know for you too. If you’re using ASP.NET Web API, you might have controllers that look like this: public class CustomerController : ApiController { private readonly ILog _log; public CustomerController(ILog log) { _log = log; } [HttpGet] public HttpResponseMessage GetCustomer(int customerId) { try { } catch (Exception e) { _log.Error(e); return Request.CreateResponse(HttpStatusCode.InternalServerError); } } } Two things can make your code

A small post for my own reference, and yours if you need it. It took me a while to get this working. In ASP.NET 5, the WebAPI Controller is no longer the same as the WebAPI 2 Controllers we’re used to. These Controllers are quite specific on how they accept content. Aurelia has an easy way of posting to a Controller: import {HttpClient} from ‘aurelia-http-client’ @inject(HttpClient) export class MyViewModel { constructor(http) { this.http = http; } callService() { this.http.post(‘http://some/url’, {