我正在使用UmbracoVirtualNodeRouteHandler
来使用一些自定义逻辑来查找我的Umbraco内容。除非我找不到内容,否则这很有效。当我找不到内容时,我想展示Umbraco 404页面。
protected override IPublishedContent FindContent(RequestContext requestContext, UmbracoContext umbracoContext)
{
var content = findMyContent();
//attempt 1
return content; //even if content is null
//end attempt 1
//attempt 2
if(content == null)
{
throw new HttpException(404, "Blogpost not found");
}
return content;
//end attempt 2
}
尝试1导致默认的无样式404页面说 “您要查找的资源已被删除,名称已更改,或暂时无法使用。”
如果找不到内容,如何显示自定义的Umbraco 404页面?
您是否尝试在umbracoSettings.config
中使用该配置?
您可以通过引用节点ID,GUID或XPATH为404页面配置自定义节点:
<errors>
<error404>1234</error404>
</errors>
<!--
The value for error pages can be:
* A content item's integer ID (example: 1234)
* A content item's GUID ID (example: 26C1D84F-C900-4D53-B167-E25CC489DAC8)
* An XPath statement (example: //errorPages[@nodeName='My cool error']
-->