diff --git a/src/Umbraco.Core/Routing/PublishedRequest.cs b/src/Umbraco.Core/Routing/PublishedRequest.cs
index badfb27dd2..e42211da49 100644
--- a/src/Umbraco.Core/Routing/PublishedRequest.cs
+++ b/src/Umbraco.Core/Routing/PublishedRequest.cs
@@ -13,7 +13,7 @@ namespace Umbraco.Web.Routing
///
/// Initializes a new instance of the class.
///
- public PublishedRequest(Uri uri, IPublishedContent publishedContent, bool isInternalRedirect, ITemplate template, DomainAndUri domain, string culture, string redirectUrl, int? responseStatusCode, IReadOnlyList cacheExtensions, IReadOnlyDictionary headers, bool cacheabilityNoCache, bool ignorePublishedContentCollisions)
+ public PublishedRequest(Uri uri, IPublishedContent publishedContent, bool isInternalRedirect, ITemplate template, DomainAndUri domain, string culture, string redirectUrl, int? responseStatusCode, IReadOnlyList cacheExtensions, IReadOnlyDictionary headers, bool setNoCacheHeader, bool ignorePublishedContentCollisions)
{
Uri = uri ?? throw new ArgumentNullException(nameof(uri));
PublishedContent = publishedContent;
@@ -25,7 +25,7 @@ namespace Umbraco.Web.Routing
ResponseStatusCode = responseStatusCode;
CacheExtensions = cacheExtensions;
Headers = headers;
- SetNoCacheHeader = cacheabilityNoCache;
+ SetNoCacheHeader = setNoCacheHeader;
IgnorePublishedContentCollisions = ignorePublishedContentCollisions;
}
diff --git a/src/Umbraco.Core/Routing/PublishedRouter.cs b/src/Umbraco.Core/Routing/PublishedRouter.cs
index 4d7f0eef82..4e0cda4041 100644
--- a/src/Umbraco.Core/Routing/PublishedRouter.cs
+++ b/src/Umbraco.Core/Routing/PublishedRouter.cs
@@ -665,7 +665,14 @@ namespace Umbraco.Web.Routing
var templateId = request.PublishedContent.TemplateId;
ITemplate template = GetTemplate(templateId);
request.SetTemplate(template);
- _logger.LogDebug("FindTemplate: Running with template id={TemplateId} alias={TemplateAlias}", template.Id, template.Alias);
+ if (template != null)
+ {
+ _logger.LogDebug("FindTemplate: Running with template id={TemplateId} alias={TemplateAlias}", template.Id, template.Alias);
+ }
+ else
+ {
+ _logger.LogWarning("FindTemplate: Could not find template with id {TemplateId}", templateId);
+ }
}
else
{
diff --git a/src/Umbraco.Core/Templates/IUmbracoComponentRenderer.cs b/src/Umbraco.Core/Templates/IUmbracoComponentRenderer.cs
index 5444ef3f96..fcfdd815f6 100644
--- a/src/Umbraco.Core/Templates/IUmbracoComponentRenderer.cs
+++ b/src/Umbraco.Core/Templates/IUmbracoComponentRenderer.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
+using System.Threading.Tasks;
using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Strings;
@@ -12,35 +13,31 @@ namespace Umbraco.Core.Templates
///
/// Renders the template for the specified pageId and an optional altTemplateId
///
- ///
+ /// The content id
/// If not specified, will use the template assigned to the node
- ///
- IHtmlEncodedString RenderTemplate(int contentId, int? altTemplateId = null);
+ Task RenderTemplateAsync(int contentId, int? altTemplateId = null);
///
/// Renders the macro with the specified alias.
///
- ///
+ /// The content id
/// The alias.
- ///
IHtmlEncodedString RenderMacro(int contentId, string alias);
///
/// Renders the macro with the specified alias, passing in the specified parameters.
///
- ///
+ /// The content id
/// The alias.
/// The parameters.
- ///
IHtmlEncodedString RenderMacro(int contentId, string alias, object parameters);
///
/// Renders the macro with the specified alias, passing in the specified parameters.
///
- ///
+ /// The content id
/// The alias.
/// The parameters.
- ///
IHtmlEncodedString RenderMacro(int contentId, string alias, IDictionary parameters);
///
diff --git a/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs b/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs
index 53e856ced4..d0b6972bc3 100644
--- a/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs
+++ b/src/Umbraco.Core/Templates/UmbracoComponentRenderer.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.IO;
using Umbraco.Web.Templates;
@@ -8,6 +8,7 @@ using Umbraco.Core.Models.PublishedContent;
using Umbraco.Core.Strings;
using Umbraco.Web;
using Umbraco.Web.Macros;
+using System.Threading.Tasks;
namespace Umbraco.Core.Templates
{
@@ -24,6 +25,9 @@ namespace Umbraco.Core.Templates
private readonly IMacroRenderer _macroRenderer;
private readonly ITemplateRenderer _templateRenderer;
+ ///
+ /// Initializes a new instance of the class.
+ ///
public UmbracoComponentRenderer(IUmbracoContextAccessor umbracoContextAccessor, IMacroRenderer macroRenderer, ITemplateRenderer templateRenderer)
{
_umbracoContextAccessor = umbracoContextAccessor;
@@ -31,76 +35,55 @@ namespace Umbraco.Core.Templates
_templateRenderer = templateRenderer ?? throw new ArgumentNullException(nameof(templateRenderer));
}
- ///
- /// Renders the template for the specified pageId and an optional altTemplateId
- ///
- ///
- /// If not specified, will use the template assigned to the node
- ///
- public IHtmlEncodedString RenderTemplate(int contentId, int? altTemplateId = null)
+ ///
+ public async Task RenderTemplateAsync(int contentId, int? altTemplateId = null)
{
using (var sw = new StringWriter())
{
try
{
- _templateRenderer.RenderAsync(contentId, altTemplateId, sw);
+ await _templateRenderer.RenderAsync(contentId, altTemplateId, sw);
}
catch (Exception ex)
{
sw.Write("", contentId, ex);
}
+
return new HtmlEncodedString(sw.ToString());
}
}
- ///
- /// Renders the macro with the specified alias.
- ///
- ///
- /// The alias.
- ///
- public IHtmlEncodedString RenderMacro(int contentId, string alias)
- {
- return RenderMacro(contentId, alias, new { });
- }
+ ///
+ public IHtmlEncodedString RenderMacro(int contentId, string alias) => RenderMacro(contentId, alias, new { });
- ///
- /// Renders the macro with the specified alias, passing in the specified parameters.
- ///
- ///
- /// The alias.
- /// The parameters.
- ///
- public IHtmlEncodedString RenderMacro(int contentId, string alias, object parameters)
- {
- return RenderMacro(contentId, alias, parameters?.ToDictionary