Sitecore - Multiple-Site Error Page Handling

戏子无情 提交于 2019-12-07 13:56:03

问题


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?


回答1:


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.




回答2:


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




回答3:


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

Hope that helps.



来源:https://stackoverflow.com/questions/4128197/sitecore-multiple-site-error-page-handling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!