Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New design for the default 404 page #11468

Merged
merged 2 commits into from
Oct 27, 2021
Merged
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 @@ -44,18 +44,14 @@ public async Task ExecuteResultAsync(ActionContext context)
reason = "No template exists to render the document at URL '{0}'.";
}

await response.WriteAsync("<html><body><h1>Page not found</h1>");
await response.WriteAsync("<h2>");
await response.WriteAsync(string.Format(reason, WebUtility.HtmlEncode(_umbracoContext.OriginalRequestUrl.PathAndQuery)));
await response.WriteAsync("</h2>");
if (string.IsNullOrWhiteSpace(_message) == false)
var viewResult = new ViewResult
{
await response.WriteAsync("<p>" + _message + "</p>");
}
ViewName = "~/umbraco/UmbracoWebsite/NotFound.cshtml"
};
context.HttpContext.Items.Add("reason", string.Format(reason, WebUtility.HtmlEncode(_umbracoContext.OriginalRequestUrl.PathAndQuery)));
context.HttpContext.Items.Add("message", _message);

await response.WriteAsync("<p>This page can be replaced with a custom 404. Check the <a target='_blank' href='https://umbra.co/custom-error-pages'>documentation for <a href=\"https://our.umbraco.com/Documentation/Tutorials/Custom-Error-Pages/#404-errors\" target=\"_blank\">Custom 404 Error Pages</a>.</p>");
await response.WriteAsync("<p style=\"border-top: 1px solid #ccc; padding-top: 10px\"><small>This page is intentionally left ugly ;-)</small></p>");
await response.WriteAsync("</body></html>");
await viewResult.ExecuteResultAsync(context);
}
}
}
1 change: 1 addition & 0 deletions src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<Content Remove="umbraco/Data/**" />
<Content Remove="umbraco/logs/**" />
<Content Remove="umbraco/mediacache/**" />
<Content Remove="umbraco\UmbracoWebsite\NotFound.cshtml" />
<Content Remove="wwwroot/Web.config" />
</ItemGroup>

Expand Down
84 changes: 84 additions & 0 deletions src/Umbraco.Web.UI/umbraco/UmbracoWebsite/NotFound.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
@using Microsoft.Extensions.Options
@using Umbraco.Cms.Core.Configuration.Models
@using Umbraco.Cms.Core.Hosting
@using Umbraco.Cms.Core.Routing
@using Umbraco.Extensions
@inject IHostingEnvironment hostingEnvironment
@inject IOptions<GlobalSettings> globalSettings
@{
var backOfficePath = globalSettings.Value.GetBackOfficePath(hostingEnvironment);
}
<!doctype html>
<html class="no-js" lang="en">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The no-js should probably not be applied unless you have some javascript to remove the script.

Alternatively add something like this:

<script>
document.documentElement.classList.remove("no-js");
</script>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

<title>Page Not Found</title>

<link rel="stylesheet" href="@WebPath.Combine(backOfficePath.TrimStart("~"), "/assets/css/nonodes.style.min.css")" />
<style type="text/css">
body {
color:initial;
}

section {
background: none;
}

section a, section a:focus, section a:visited {
color:initial;
border-color:currentColor;
}
</style>
</head>
<body>

<section>
<article>
<div>
<h1>Page Not Found</h1>
@if (hostingEnvironment.IsDebugMode)
{

var reason = (string)Context.Items["reason"];
var message = (string)Context.Items["message"];

if (!reason.IsNullOrWhiteSpace())
{
<h3>@reason</h3>
}
if (!message.IsNullOrWhiteSpace())
{
<p>@message</p>
}

<div class="cta"></div>

<div class="row">
<div class="col">
<h2>This page can be replaced</h2>
<p>
Custom error handling might make your site look more on-brand and minimize the impact of errors on user experience - for example, a custom 404 with some helpful links (or a search function) could bring some value to the site.
</p>

<a href="https://umbra.co/custom-error-pages" target="_blank" rel="noopener">Implementing custom error pages &rarr;</a>
</div>

<div class="col">
<h2>Be a part of the community</h2>
<p>The Umbraco community is the best of its kind, be sure to visit, and if you have any questions, we're sure that you can get your answers from the community.</p>

<a href="https://our.umbraco.com/" target="_blank" rel="noopener">our.Umbraco &rarr;</a>
</div>
</div>

}
</div>
</article>

</section>

</body>
</html>