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/Program.cs b/EssentialCSharp.Web/Program.cs index 42df3e32..ba72d4dd 100644 --- a/EssentialCSharp.Web/Program.cs +++ b/EssentialCSharp.Web/Program.cs @@ -141,6 +141,7 @@ private static void Main(string[] args) options.HttpsPort = 443; }); + ConfigurationManager configuration = builder.Configuration; string connectionString = builder.Configuration.GetConnectionString("EssentialCSharpWebContextConnection") ?? throw new InvalidOperationException("Connection string 'EssentialCSharpWebContextConnection' not found."); diff --git a/EssentialCSharp.Web/Views/Shared/_Layout.cshtml b/EssentialCSharp.Web/Views/Shared/_Layout.cshtml index d4968377..9dd1bc5e 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)