Umbraco中如何找到home node

Posted wphl-27

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Umbraco中如何找到home node相关的知识,希望对你有一定的参考价值。

在一个Umbraco项目中,我们经常会出现需要找到这个项目的home node的情况, 那么如何来找到项目的home node呢

方法如下:

 

1. 在View中

@inherits Umbraco.Web.Mvc.UmbracoTemplatePage

@{
    IPublishedContent homePage = Model.Content.AncestorOrSelf("Home");
}

2. 在Controller中

using Umbraco.Web;
using Umbraco.Core.Models;
using System.Linq;

IPublishedContent homePage = CurrentPage.AncestorOrSelf("Home");

 

以上是关于Umbraco中如何找到home node的主要内容,如果未能解决你的问题,请参考以下文章