episerver- iContentLoader在过滤开始页面时返回不同的页面类型
我正在尝试在剃须刀代码中获取启动页面,以便我可以根据开始页面显示不同的NAV。这就是我的操作方式:
var contentLoader = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentLoader>();
var pages = contentLoader.GetChildren<PageData>(ContentReference.StartPage);
这是在调试器中显示的内容。我期望只看到类型,开始。但是我看到了英雄页面和所有内容。有什么想法在这里发生了什么?
I'm trying to get the start pages in Razor code so I can display different navs based on the start page. Here's how I'm doing it:
var contentLoader = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentLoader>();
var pages = contentLoader.GetChildren<PageData>(ContentReference.StartPage);
This is what shows up in the debugger. I was expecting to only see pages of type, Start. But I'm seeing Hero pages and everything. Any ideas what's going on here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想获取开始页面(仅一个实例),并且它是在管理模式下以启动页面为单位的开始页面以用于您网站的配置,则应执行以下操作
If you want to get the start page (just one instance) and it is the same start page that is selected as start page in admin mode for the configuration of your site you should do the following
我能够通过传递根本页面的ContentReference和我的开始页面对象来解决此问题。
I was able to resolve this by passing in the ContentReference for the root page and my start page object.