C# Umbraco自定义url段塞
每次用户创建新节点时,我都需要生成一个自定义url段塞,或者(如果可能)完全停止使用C# Umbraco自定义url段塞,c#,asp.net,umbraco,C#,Asp.net,Umbraco,每次用户创建新节点时,我都需要生成一个自定义url段塞,或者(如果可能)完全停止使用Umbraco.library:NiceUrl方法。在我的回答中,我假设您使用的是Umbraco v4.7.x 首先,我要确保您的节点上有documenttype属性和/或属性(我将让您决定哪个最适合您的需求) 然后可以订阅Document.New事件处理程序。要订阅Document.New处理程序,您需要从ApplicationBase类继承,请参见以下示例: public class ApplicationB
Umbraco.library:NiceUrl
方法。在我的回答中,我假设您使用的是Umbraco v4.7.x
首先,我要确保您的节点上有documenttype属性和/或属性(我将让您决定哪个最适合您的需求)
然后可以订阅Document.New事件处理程序。要订阅Document.New处理程序,您需要从ApplicationBase类继承,请参见以下示例:
public class ApplicationBase : umbraco.BusinessLogic.ApplicationBase
{
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationBase"/> class.
/// </summary>
public ApplicationBase()
{
Document.New += this.Document_New;
}
private void Document_New(Document sender, NewEventArgs e)
{
sender.getProperty("umbracoUrlName").Value = "your_urlname_here";
sender.Save();
}
}
公共类应用程序库:umbraco.BusinessLogic.ApplicationBase
{
///
///初始化类的新实例。
///
公共应用程序库()
{
Document.New+=此.Document\u New;
}
私有无效文档\u新建(文档发送者,NewEventArgs e)
{
sender.getProperty(“umbracoUrlName”).Value=“您的”urlname“在这里”;
sender.Save();
}
}