Skip to content

Commit

Permalink
Improve performance with many threads
Browse files Browse the repository at this point in the history
  • Loading branch information
304NotModified committed May 1, 2017
1 parent 0fca141 commit f967e29
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion NLog.Web.AspNetCore/LayoutRenderers/AspNetLayoutRendererBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,21 @@ protected AspNetLayoutRendererBase()
/// <returns>HttpContextAccessor or <c>null</c></returns>
public IHttpContextAccessor HttpContextAccessor
{
get { return _httpContextAccessor ?? ServiceLocator.ServiceProvider?.GetService<IHttpContextAccessor>(); }
get { return _httpContextAccessor ?? (_httpContextAccessor = ServiceLocator.ServiceProvider?.GetService<IHttpContextAccessor>()); }
set { _httpContextAccessor = value; }
}

/// <summary>
/// Initialize
/// </summary>
protected override void InitializeLayoutRenderer()
{
if (HttpContextAccessor == null)
{
Common.InternalLogger.Warn("Missing IHttpContextAccessor. Has it been registered before loading NLog Configuration? Consider reloading NLog Configuration after having registered the IHttpContextAccessor.");
}
}

#else
/// <summary>
/// Provides access to the current request HttpContext.
Expand Down

0 comments on commit f967e29

Please sign in to comment.