diff --git a/src/Umbraco.Web.Common/ActionsResults/PublishedContentNotFoundResult.cs b/src/Umbraco.Web.Common/ActionsResults/PublishedContentNotFoundResult.cs
index 2ef9a5e4b34f..0eb30bcd0377 100644
--- a/src/Umbraco.Web.Common/ActionsResults/PublishedContentNotFoundResult.cs
+++ b/src/Umbraco.Web.Common/ActionsResults/PublishedContentNotFoundResult.cs
@@ -44,18 +44,14 @@ public async Task ExecuteResultAsync(ActionContext context)
reason = "No template exists to render the document at URL '{0}'.";
}
- await response.WriteAsync("
Page not found ");
- await response.WriteAsync("");
- await response.WriteAsync(string.Format(reason, WebUtility.HtmlEncode(_umbracoContext.OriginalRequestUrl.PathAndQuery)));
- await response.WriteAsync(" ");
- if (string.IsNullOrWhiteSpace(_message) == false)
+ var viewResult = new ViewResult
{
- await response.WriteAsync("" + _message + "
");
- }
+ 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("This page can be replaced with a custom 404. Check the documentation for Custom 404 Error Pages .
");
- await response.WriteAsync("This page is intentionally left ugly ;-)
");
- await response.WriteAsync("");
+ await viewResult.ExecuteResultAsync(context);
}
}
}
diff --git a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
index bae39162f470..622766b4b15e 100644
--- a/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
+++ b/src/Umbraco.Web.UI/Umbraco.Web.UI.csproj
@@ -43,6 +43,7 @@
+
diff --git a/src/Umbraco.Web.UI/umbraco/UmbracoWebsite/NotFound.cshtml b/src/Umbraco.Web.UI/umbraco/UmbracoWebsite/NotFound.cshtml
new file mode 100644
index 000000000000..62a149f2ab9d
--- /dev/null
+++ b/src/Umbraco.Web.UI/umbraco/UmbracoWebsite/NotFound.cshtml
@@ -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
+@{
+ var backOfficePath = globalSettings.Value.GetBackOfficePath(hostingEnvironment);
+}
+
+
+
+
+
+
+
+ Page Not Found
+
+
+
+
+
+
+
+
+
+
Page Not Found
+ @if (hostingEnvironment.IsDebugMode)
+ {
+
+ var reason = (string)Context.Items["reason"];
+ var message = (string)Context.Items["message"];
+
+ if (!reason.IsNullOrWhiteSpace())
+ {
+
@reason
+ }
+ if (!message.IsNullOrWhiteSpace())
+ {
+
@message
+ }
+
+
+
+
+
+
This page can be replaced
+
+ 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.
+
+
+
Implementing custom error pages →
+
+
+
+
Be a part of the community
+
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.
+
+
our.Umbraco →
+
+
+
+ }
+
+
+
+
+
+
+