diff --git a/EssentialCSharp.Web/Extensions/IServiceCollectionExtensions.cs b/EssentialCSharp.Web/Extensions/IServiceCollectionExtensions.cs index 1c3806ca..2d69e217 100644 --- a/EssentialCSharp.Web/Extensions/IServiceCollectionExtensions.cs +++ b/EssentialCSharp.Web/Extensions/IServiceCollectionExtensions.cs @@ -27,7 +27,7 @@ public static void AddTrustedForwardedHeaders(this IServiceCollection services, services.Configure(options => { options.ForwardedHeaders = - ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto; + ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost; options.ForwardLimit = 1; var trustedProxyCidrs = configuration diff --git a/EssentialCSharp.Web/Views/Shared/_Layout.cshtml b/EssentialCSharp.Web/Views/Shared/_Layout.cshtml index bc2396fc..5d1d84b4 100644 --- a/EssentialCSharp.Web/Views/Shared/_Layout.cshtml +++ b/EssentialCSharp.Web/Views/Shared/_Layout.cshtml @@ -19,11 +19,17 @@ const string imageUrl = "https://essentialcsharp.com/images/icon.png"; const string description = "Accelerate your development knowledge with C# expert Mark Michaelis and Benjamin Michaelis' free, online comprehensive C# tutorial and reference that is updated through C# 11.0"; string title = $"Essential C#{(string.IsNullOrEmpty(ViewBag.PageTitle) ? string.Empty : $": {ViewBag.PageTitle}")}"; + string canonicalPath = $"{Context.Request.PathBase}{Context.Request.Path}"; + if (string.IsNullOrEmpty(canonicalPath)) + { + canonicalPath = "/"; + } + string canonicalUrl = $"{Context.Request.Scheme}://{Context.Request.Host}{canonicalPath}"; } - + @@ -82,6 +88,7 @@ + @await RenderSectionAsync("HeadAppend", required: false)