2012-09-07 08:28:18 +07:00
|
|
|
|
using System.Web;
|
2012-08-08 23:10:34 +06:00
|
|
|
|
|
2012-09-07 08:28:18 +07:00
|
|
|
|
namespace Umbraco.Web.Routing
|
2012-08-08 23:10:34 +06:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets executed when no document can be found in Umbraco
|
|
|
|
|
|
/// </summary>
|
2012-10-02 01:43:59 +05:00
|
|
|
|
internal class PublishedContentNotFoundHandler : IHttpHandler
|
2012-08-08 23:10:34 +06:00
|
|
|
|
{
|
|
|
|
|
|
public void ProcessRequest(HttpContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
WriteOutput(context);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void WriteOutput(HttpContext context)
|
|
|
|
|
|
{
|
2012-09-24 11:36:25 -02:00
|
|
|
|
var response = context.Response;
|
2012-08-08 23:10:34 +06:00
|
|
|
|
|
2012-09-24 11:36:25 -02:00
|
|
|
|
response.Clear();
|
2012-08-08 23:10:34 +06:00
|
|
|
|
|
2012-10-02 01:40:19 +05:00
|
|
|
|
var docreq = UmbracoContext.Current.PublishedContentRequest;
|
2012-09-24 11:36:25 -02:00
|
|
|
|
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}'.";
|
2012-08-08 23:10:34 +06:00
|
|
|
|
|
2012-09-24 11:36:25 -02:00
|
|
|
|
response.Write("<html><body><h1>Page not found</h1>");
|
|
|
|
|
|
response.Write("<h3>");
|
2012-10-26 02:55:57 +05:00
|
|
|
|
response.Write(string.Format(reason, HttpUtility.HtmlEncode(UmbracoContext.Current.OriginalRequestUrl)));
|
2012-09-24 11:36:25 -02:00
|
|
|
|
response.Write("</h3");
|
|
|
|
|
|
response.Write("<p>This page can be replaced with a custom 404. Check the documentation for \"custom 404\".</p>");
|
|
|
|
|
|
response.Write("<p style=\"border-top: 1px solid #ccc; padding-top: 10px\"><small>This page is intentionally left ugly ;-)</small></p>");
|
|
|
|
|
|
response.Write("</body></html>");
|
|
|
|
|
|
|
|
|
|
|
|
response.End();
|
2012-08-08 23:10:34 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public bool IsReusable
|
|
|
|
|
|
{
|
2012-09-24 11:36:25 -02:00
|
|
|
|
get { return true; }
|
2012-08-08 23:10:34 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|