我已在 Orchard CMS 网站上创建了自定义 404 页面和自定义错误页面,如 David Haydan's Blog 中所述。
自定义模板工作正常。但是,错误显示时没有任何正常的页面布局。或样式
如何使用默认的 Layout.cshtml 来呈现此内容?
当我切换到主题机 Theme 时也会发生这种情况。
最佳答案
您是否使用重写规则模块?
如果是这种情况,则此问题已在此处报告:http://orchardrewriterules.codeplex.com/workitem/11
它说:“它可以通过 ThemedAttribute 修复”。这是通过在项目 Contrib.RewriteRules/Controllers/HomeController.cs 的 HomeController 中添加属性“Themed”来完成的。完成后,它将如下所示:
using Orchard.Themes;
using System.Web.Mvc;
namespace Contrib.RewriteRules.Controllers {
[Themed]
public class HomeController : Controller {
public ActionResult Rewrite(string path) {
return new HttpNotFoundResult();
}
}
}
(重现错误很简单。启动一个全新的 Orchard 站点,并测试 404 是否可以与 Theme Machine 配合使用。然后我安装并启用“重写规则”模块版本 1.2.5,您应该能够看到没有布局的NotFound.cshtml的内容。禁用重写规则模块可以恢复正常。)
关于http-status-code-404 - Orchard Cms 自定义 404 不会在正常页面布局中显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14585136/