标签: umbraco8

无法从 ContentService 使用 SaveAndPublish

我正在尝试保存我的IContent呼叫child,但在这一行(contentService.SaveAndPublish(child);)上我收到以下错误:Object reference not set to an instance of an object.

\n\n
if (child.HasProperty("navn"))\n{\n    child.SetValue("navn", worker.Name.ToString(), "da-dk");\n}\ncontentService.SaveAndPublish(child);\n
Run Code Online (Sandbox Code Playgroud)\n\n

这就是我定义我的contentService
IContentService contentService = Umbraco.Core.Composing.Current.Services.ContentService;

\n\n

我发现孩子们是这样的:

\n\n
long totalChildren;\n\nIEnumerable<IContent> children = contentService.GetPagedChildren(filialsParent.Id, 0, 100, out totalChildren);\n
Run Code Online (Sandbox Code Playgroud)\n\n

\xc2\xb4\n有人能指出这里出了什么问题吗?

\n

umbraco umbraco8

5
推荐指数
1
解决办法
1436
查看次数

如何将razor生成的html转换为字符串?

我使用 umbraco 创建了一个工作流程,我想做的是:创建一个工作流程,获取由 razor 模板 ( umbraco.forms) 创建的 html。

这是模板的位置umbraco.forms

Views\Partials\Forms\Emails 此模板是我想要在调用此工作流程时通过电子邮件发送的模板。

public class SendMail : WorkflowType
{  
    //Here I get the path where the razor template is
    [Umbraco.Forms.Core.Attributes.Setting("Path to template",
     Description = "Path to template",
     View = "TextField")]
     public string Template{ get; set; }
   public SendMail()
   {

    this.Id = new Guid("ccbeb0d5-adaa-4729-8b4c-4bb439dc0204");
    this.Name = "Send Mail";
    this.Description = "Send Mail";
    this.Icon = "icon-plugin";
    this.Group = "Services";
   }
    //When workflow get called this method is executed 
    public override WorkflowExecutionStatus …
Run Code Online (Sandbox Code Playgroud)

c# umbraco umbraco8

5
推荐指数
1
解决办法
1940
查看次数

Umbraco 8 和 IoC

我安装了 Umbraco 8.1.3,并尝试按照这篇文章配置依赖注入,但不起作用。我的代码是:

控制器:

public class ContactController : UmbracoApiController
{
    private readonly IContactService contactService;

    public ContactController(IContactService contactService)
    {
        this.contactService = contactService;
    }

    [HttpPost]
    public void Post([FromBody]ContactDto request)
    {
        this.contactService.Register(request);
    }
}
Run Code Online (Sandbox Code Playgroud)

服务:

public interface IContactService
{
    void Register(ContactDto contact);
}



public class ContactService : IContactService
{
    public ContactService()
    {
    }

    public void Register(ContactDto contact)
    {
      //Implement
    }
}
Run Code Online (Sandbox Code Playgroud)

DI 配置:

public class ApplicationComposer : IUserComposer
{
    public void Compose(Composition composition)
    {
        composition.RegisterFor<IContactService, ContactService>();
    }
}
Run Code Online (Sandbox Code Playgroud)

错误是:

"Message": "发生错误。", …

dependency-injection inversion-of-control umbraco8

4
推荐指数
1
解决办法
1573
查看次数

如何从 Umbraco 中的特定文化中获取内容

我有双语网站,德语设置为默认语言,我正在尝试从 SurfaceController 获取英语内容节点,如下所示:

Umbraco.Content(ID);
Run Code Online (Sandbox Code Playgroud)

我试图像这样改变当前的文化:

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
Run Code Online (Sandbox Code Playgroud)

但没有成功。

c# asp.net umbraco umbraco8

2
推荐指数
1
解决办法
1459
查看次数

Umbraco 检查文件锁定 Azure 应用服务

我们在一系列负载平衡的 Azure 应用服务中运行 Umbraco 8.1.5 网站,并且在其中一个实例中遇到了检查/Lucene 文件锁定问题。我们已尝试将Examine升级到1.0.2,但这仍然没有帮助。

据我所知,我们已遵循所有文档来设置 Umbraco 以在 Azure 应用服务负载平衡环境中运行。

有没有人在可缩放/自动缩放的 Azure 应用服务中使用 Umbraco 8 进行负载平衡?

应用服务

管理 - 一个实例,无自动缩放前端 - 缩放至两个实例

在其中一台前端服务器上,我们访问外部索引的搜索控制器正在工作,但在另一个实例上,它错误地指出索引文件已锁定。下面提供了错误消息。

如果我们将前端扩展到单个实例,则搜索始终有效。

设置

服务器角色

管理 web.config 应用程序设置

<add key="UmbracoServerRegistrar" value="master" />
Run Code Online (Sandbox Code Playgroud)

前端 web.config 应用程序设置

<add key="UmbracoServerRegistrar" value="slave" />
Run Code Online (Sandbox Code Playgroud)

这是在下面的作曲家中摘录的

public class ServerRegistrarComposer : IUserComposer
{
    public void Compose(Composition composition)
    {
        var config = System.Configuration.ConfigurationManager.AppSettings["UmbracoServerRegistrar"];
        if (config != null && config.Equals("slave", StringComparison.InvariantCultureIgnoreCase))
        {
            composition.SetServerRegistrar(new FrontEndReadOnlyServerRegistrar());
        }
        else
        {
            composition.SetServerRegistrar(new MasterServerRegistrar());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

注册商

public class FrontEndReadOnlyServerRegistrar …
Run Code Online (Sandbox Code Playgroud)

load-balancing examine umbraco8

2
推荐指数
1
解决办法
1400
查看次数

使用 IdentityServer4 登录 Umbraco 8 后台

背景

我对 Umbraco 很陌生,但一直在尝试使用IdentityServer4作为 Umbraco 的后台。对于 IDP,我使用了此处的内存配置(is4inmem 模板)。

对于 Umbraco,我使用UmbracoIdentityExtensions来配置 OpenId Connect。

我主要关注的是教程(不过这是针对 Umbraco 7 的)。

问题

我确实有配置的“使用 OpenId 连接登录”按钮,但是当我尝试使用 IDP 登录时,Umbraco 不会让我登录。我总是返回到登录页面。然而,每当我访问 IDP 页面时,我都会登录并可以看到我已授予访问权限,如下图所示。 在此输入图像描述

每当我使用 Umbraco 帐户登录,然后尝试“链接您的 OpenId Connect 帐户”时,它什么也不做,但注销后屏幕上会出现一条错误消息:“发生错误,无法获取外部登录信息”尝试过使用不同的配置设置,但没有成功。

代码

IDP 配置.cs

public static IEnumerable<IdentityResource> Ids =>
            new IdentityResource[]
            {
                new IdentityResources.OpenId(),
                new IdentityResources.Profile(),
                new IdentityResources.Email(),
                new IdentityResource(
                    name: "application.profile",
                    displayName: "Application profile",
                    claimTypes: new[] { ClaimTypes.GivenName, ClaimTypes.Surname }
                )
            };

... etc ...

 public static IEnumerable<Client> Clients =>
            new …
Run Code Online (Sandbox Code Playgroud)

c# identityserver4 umbraco8

1
推荐指数
1
解决办法
1298
查看次数