Sitecore - 多站点错误页面处理

发布于 2024-10-01 09:41:15 字数 163 浏览 3 评论 0原文

我有一个多站点 Sitecore 项目。我知道如何通过 webconfig 的 ErrorPage、ItemNotFoundUrl、LayoutNotFoundUrl、LinkItemNotFoundUrl 处理一个站点的错误页面。

但是,我想为每个站点显示不同的错误页面。我怎样才能做到这一点?

I have a multiple-site Sitecore project. I know how to deal with error pages via the webconfig's ErrorPage, ItemNotFoundUrl, LayoutNotFoundUrl, LinkItemNotFoundUrl for one site.

However, I'm wanting to display a different error pages for each site. How can I accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梓梦 2024-10-08 09:41:15

在任何情况下,您都可以通过扩展 Sitecore.Sites 将每个站点的错误页面的 URL 存储为 web.config 中 /configuration/sitecore/sites/site 元素的属性.SiteContext 类(请参阅有关扩展现有类的信息)。

SDN 论坛帖子专门提供了有关 404 的更多信息/ItemNotFound 条件,包括 Sitecore.SItes.SiteContext 扩展的示例。

对于 ItemNotFoundUrl,我认为这取决于您是否使用项目或文件作为 404 页面。如果您使用项目处理 404,则在项目解析器之后,将处理器添加到 httpRequestBegin 管道,以将上下文项设置为该站点的 404 项(如果上下文项为 null)。如果您使用文件,那么我认为重写 Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleItemNotFound()Sitecore.Resources.Media.MediaRequestHandler.DoProcessRequest() 并更新相应的web.config 文件中的引用。

对于 ErrorPage,我认为您必须覆盖 Sitecore.Pipelines.RenderLayout.SecurityCheck.P​​rocess 并更新 web.config 中的相应引用。

对于 LayoutNotFoundUrl ,我认为您必须重写 Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleLayoutNotFound ,并更新 web.config 中的相应引用。

对于 LinkItemNotFoundUrl,我可能会向 renderField 管道添加一个处理器,以将设置的默认值替换为适用于上下文站点的值。

如果这是一个常见的需求,我们应该将其变成Sitecore共享源项目,或者将其添加到现有项目中。

In any case, you can probably store the URLs of the error pages for each site as attributes of the /configuration/sitecore/sites/site elements in web.config by extending the Sitecore.Sites.SiteContext class (see for information about extending existing classes).

The SDN forum post provides more information specifically about the 404 /ItemNotFound condition, including an example of an extension of Sitecore.SItes.SiteContext.

For ItemNotFoundUrl, I think it depends on whether you use an item or a file as the 404 page. If you handle 404 with items, then after the item resolver, add a processor to the httpRequestBegin pipeline to set the context item to the 404 item for that site if the context item is null. If you use files, then I think override Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleItemNotFound() and Sitecore.Resources.Media.MediaRequestHandler.DoProcessRequest() and update the corresponding references in the web.config file.

For ErrorPage, I think you would have to override Sitecore.Pipelines.RenderLayout.SecurityCheck.Process and update the corresponding reference in web.config.

For LayoutNotFoundUrl, I think you would have to override Sitecore.Pipelines.HttpRequest.ExecuteRequest.HandleLayoutNotFound, and update the corresponding reference in web.config.

For LinkItemNotFoundUrl, I would probably add a processor to the renderField pipeline to perform replacement of the default value of the setting with the value that applies for the context site.

If this is a common requirement, we should turn it into a Sitecore Shared Source project, or add it to an existing project.

流云如水 2024-10-08 09:41:15

在 SDN 剪贴簿中有一个 条目,介绍如何对多- 现场安装。

There's an entry in the SDN scrapbook about how to do this for a multi-site install.

以歌曲疗慰 2024-10-08 09:41:15

有一个共享源项目应该满足大部分要求。它称为 Sitecore 错误管理器

希望有帮助。

There is a Shared Source project which should fit the requirements is most parts. It's called Sitecore Error Manager.

Hope that helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文