AB#6233 - Install in .NET Core
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Umbraco.Web.Common.AspNetCore
|
||||
|
||||
var cookieValue = httpContext.Request.Cookies[cookieName];
|
||||
|
||||
httpContext.Response.Cookies.Append(cookieName, cookieValue, new CookieOptions()
|
||||
httpContext.Response.Cookies.Append(cookieName, cookieValue ?? string.Empty, new CookieOptions()
|
||||
{
|
||||
Expires = DateTime.Now.AddYears(-1)
|
||||
});
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Web.Common.Extensions;
|
||||
using Umbraco.Web.Routing;
|
||||
|
||||
namespace Umbraco.Web.Common.AspNetCore
|
||||
{
|
||||
public class AspNetCoreRequestAccessor : IRequestAccessor
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
public AspNetCoreRequestAccessor(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
public string GetRequestValue(string name) => GetFormValue(name) ?? GetQueryStringValue(name);
|
||||
public string GetFormValue(string name) => _httpContextAccessor.GetRequiredHttpContext().Request.Form[name];
|
||||
|
||||
public string GetQueryStringValue(string name) => _httpContextAccessor.GetRequiredHttpContext().Request.Query[name];
|
||||
|
||||
//TODO implement
|
||||
public event EventHandler<UmbracoRequestEventArgs> EndRequest;
|
||||
|
||||
//TODO implement
|
||||
public event EventHandler<RoutableAttemptEventArgs> RouteAttempt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Web.Common.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