Moved files from backoffice into Common + Introduced AspNetCoreComponent to invoke the Umbraco Application Init event
This commit is contained in:
@@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user