Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static void AddTrustedForwardedHeaders(this IServiceCollection services,
services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto | ForwardedHeaders.XForwardedHost;
options.ForwardLimit = 1;

var trustedProxyCidrs = configuration
Expand Down
1 change: 1 addition & 0 deletions EssentialCSharp.Web/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ private static void Main(string[] args)

builder.Services.AddTrustedForwardedHeaders(builder.Configuration, builder.Environment);


ConfigurationManager configuration = builder.Configuration;
string connectionString = builder.Configuration.GetConnectionString("EssentialCSharpWebContextConnection") ?? throw new InvalidOperationException("Connection string 'EssentialCSharpWebContextConnection' not found.");

Expand Down
9 changes: 8 additions & 1 deletion EssentialCSharp.Web/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -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}";
}
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://essentialcsharp.com/" />
<meta property="og:url" content="@canonicalUrl" />
<meta property="og:image:secure_url" content="@imageUrl" />
<meta property="og:image" content="@imageUrl" />
<meta name="twitter:image" content="@imageUrl" />
Expand Down Expand Up @@ -100,6 +106,7 @@
<script src="~/js/hcaptcha-form.js" asp-append-version="true"></script>
<!-- hCaptcha Script -->
<script src="https://js.hcaptcha.com/1/api.js?render=explicit&onload=ecsOnHcaptchaLoad" async defer></script>
<link rel="canonical" href="@canonicalUrl" />
@await RenderSectionAsync("HeadAppend", required: false)
</head>
<body>
Expand Down