Return a JSON error response from file download

If you prefer to receive a JSON error response when downloading a file then append format=json in the query string.

A note for users of CM 9.1

In 9.1 there is a bug which causes the HTML error page to be returned with the HTTP status code 200, rather than an error code. If you return JSON then you will get an appropriate error code (probably a 500). To fix 9.2:

  1. edit the file: \RazorPages\GlobalErrors.cshtml
  2. add this code into the head: this.Response.StatusCode = 500;


Written on May 29, 2019