Added 404 status code to article view on not-found state, to inform search engines of deleted articles

This commit is contained in:
Mia Rose Winter 2024-04-18 14:32:12 +02:00
parent 4a265f30b7
commit d28625c37b
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E

View file

@ -4,6 +4,7 @@
@using Wave.Data
@using System.Security.Claims
@using System.Globalization
@using System.Net
@using Microsoft.AspNetCore.Identity
@using Microsoft.Extensions.Options
@using Wave.Services
@ -181,6 +182,10 @@
a.PublishDate.Date == date.Date
&& (slug != null && a.Slug == slug || a.Title.ToLower() == title));
}
if (Article is null) {
HttpContext.Response.StatusCode = (int)HttpStatusCode.NotFound;
}
}
protected override async Task OnInitializedAsync() {