using System.Web;
namespace Umbraco.Web.Routing
{
///
/// Gets executed when no document can be found in Umbraco
///
internal class PublishedContentNotFoundHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
WriteOutput(context);
}
internal void WriteOutput(HttpContext context)
{
var response = context.Response;
response.Clear();
var docreq = UmbracoContext.Current.PublishedContentRequest;
var reason = "Cannot render the page at url '{0}'.";
if (!docreq.HasNode)
reason = "No umbraco document matches the url '{0}'.";
else if (!docreq.HasTemplate)
reason = "No template exists to render the document at url '{0}'.";
response.Write("
Page not found
");
response.Write("");
response.Write(string.Format(reason, HttpUtility.HtmlEncode(UmbracoContext.Current.OriginalRequestUrl)));
response.Write("
This page can be replaced with a custom 404. Check the documentation for \"custom 404\".");
response.Write("This page is intentionally left ugly ;-)
");
response.Write("");
response.End();
}
public bool IsReusable
{
get { return true; }
}
}
}