public async Task Invoke(HttpContext ctx) { // Setup an AuthContext for the duration of the request AuthContext.BuildFrom(ctx, true); var cLen = ctx.Request.ContentLength; var cType = ctx.Request.ContentType; var method = ctx.Request.Method; if (HttpMethods.IsPut(method) || HttpMethods.IsPost(method)) { if (string.IsNullOrEmpty(cType)) { if (cLen.HasValue) { ctx.Request.ContentType = "application/json"; } } } await _next(ctx); }