Added missing content-type header to BootFailedMiddleware response

When Umbraco is configured with X-Content-Type-Options nosniff as is recommended (there's even a health check for it), any boot failure would simply show the html source code in the browser instead of properly rendering the html, as the content-type wasn't being set.

(cherry picked from commit d4c921264d)
This commit is contained in:
Vitor Rodrigues
2022-10-26 09:28:07 +02:00
committed by Sebastiaan Janssen
parent dc2701cb5e
commit ea3c862228

View File

@@ -1,3 +1,4 @@
using System.Net.Mime;
using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@@ -51,6 +52,7 @@ public class BootFailedMiddleware : IMiddleware
// Print a nice error page
context.Response.Clear();
context.Response.StatusCode = 500;
context.Response.ContentType = MediaTypeNames.Text.Html;
IFileInfo? fileInfo = GetBootErrorFileInfo();
if (fileInfo is not null)