![ASP.NET core](https://ardalis.com/static/2bcf8d1ec45106e529bb3a6176467a31/c5cb2/aspnetcore-logo.png)
Add this to the middleware pipeline
app.UseStatusCodePages(new StatusCodePagesOptions()
{
HandleAsync = (ctx) =>
{
if (ctx.HttpContext.Response.StatusCode == 404)
{
ctx.HttpContext.Response.ContentType = Text.Html;
ctx.HttpContext.Response.WriteAsync(
$"<div style='text-align: center'><h1 style='margin-top: 100px'>My Server Is Working</h1></div>");
}
return Task.FromResult(0);
}
});
Tags
ASP .NET core