Moved files from backoffice into Common + Introduced AspNetCoreComponent to invoke the Umbraco Application Init event

This commit is contained in:
Bjarke Berg
2020-03-27 11:39:17 +01:00
parent fe88662f48
commit 681a25b861
26 changed files with 134 additions and 102 deletions

View File

@@ -0,0 +1,30 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Umbraco.Net;
namespace Umbraco.Web.Common.AspNetCore
{
internal class AspNetCoreSessionIdResolver : ISessionIdResolver
{
private readonly IHttpContextAccessor _httpContextAccessor;
public AspNetCoreSessionIdResolver(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string SessionId
{
get
{
var httpContext = _httpContextAccessor?.HttpContext;
// If session isn't enabled this will throw an exception so we check
var sessionFeature = httpContext?.Features.Get<ISessionFeature>();
return sessionFeature != null
? httpContext?.Session?.Id
: "0";
}
}
}
}