Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Umbraco自定义url段塞_C#_Asp.net_Umbraco - Fatal编程技术网

C# Umbraco自定义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

每次用户创建新节点时,我都需要生成一个自定义url段塞,或者(如果可能)完全停止使用
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();
}    
}