From ea3c862228084f41491b98de1b9c87574d889e54 Mon Sep 17 00:00:00 2001 From: Vitor Rodrigues Date: Wed, 26 Oct 2022 09:28:07 +0200 Subject: [PATCH] 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 d4c921264d50cd8adc31b1671e00b9b218d54761) --- src/Umbraco.Web.Common/Middleware/BootFailedMiddleware.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Umbraco.Web.Common/Middleware/BootFailedMiddleware.cs b/src/Umbraco.Web.Common/Middleware/BootFailedMiddleware.cs index 11abf725c2..70c4d0c8b8 100644 --- a/src/Umbraco.Web.Common/Middleware/BootFailedMiddleware.cs +++ b/src/Umbraco.Web.Common/Middleware/BootFailedMiddleware.cs @@ -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)