Added more aspnet core implementation of interfaces
This commit is contained in:
@@ -26,10 +26,15 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
// IISVersion = HttpRuntime.IISVersion;
|
||||
IsDebugMode = _hostingSettings.DebugMode;
|
||||
}
|
||||
|
||||
public bool IsHosted { get; } = true;
|
||||
public string SiteName { get; }
|
||||
public string ApplicationId { get; }
|
||||
public string ApplicationPhysicalPath { get; }
|
||||
|
||||
public string ApplicationVirtualPath { get; }
|
||||
public bool IsDebugMode { get; }
|
||||
|
||||
|
||||
public string LocalTempPath
|
||||
{
|
||||
get
|
||||
@@ -67,9 +72,7 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
}
|
||||
}
|
||||
}
|
||||
public string ApplicationVirtualPath { get; }
|
||||
public bool IsDebugMode { get; }
|
||||
public bool IsHosted { get; } = true;
|
||||
|
||||
public Version IISVersion { get; }
|
||||
public string MapPath(string path) => Path.Combine(_webHostEnvironment.WebRootPath, path);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Web;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Net;
|
||||
|
||||
@@ -13,6 +12,6 @@ namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public string GetCurrentRequestIpAddress() => _httpContextAccessor?.HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? String.Empty;
|
||||
public string GetCurrentRequestIpAddress() => _httpContextAccessor?.HttpContext?.Connection?.RemoteIpAddress?.ToString() ?? string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Threading;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Web.AspNet
|
||||
{
|
||||
public class AspNetCoreUmbracoApplicationLifetime : IUmbracoApplicationLifetime
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly IApplicationLifetime _applicationLifetime;
|
||||
|
||||
public AspNetCoreUmbracoApplicationLifetime(IHttpContextAccessor httpContextAccessor, IApplicationLifetime applicationLifetime)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_applicationLifetime = applicationLifetime;
|
||||
}
|
||||
|
||||
public bool IsRestarting { get; set; }
|
||||
public void Restart()
|
||||
{
|
||||
IsRestarting = true;
|
||||
|
||||
var httpContext = _httpContextAccessor.HttpContext;
|
||||
if (httpContext != null)
|
||||
{
|
||||
// unload app domain - we must null out all identities otherwise we get serialization errors
|
||||
// http://www.zpqrtbnk.net/posts/custom-iidentity-serialization-issue
|
||||
httpContext.User = null;
|
||||
}
|
||||
|
||||
Thread.CurrentPrincipal = null;
|
||||
_applicationLifetime.StopApplication();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Web.BackOffice.AspNetCore
|
||||
{
|
||||
public class AspNetCoreUserAgentProvider : IUserAgentProvider
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public AspNetCoreUserAgentProvider(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public string GetUserAgent()
|
||||
{
|
||||
return _httpContextAccessor.HttpContext.Request.Headers["User-Agent"].ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user