Goodbye HttpContextAccessor
This commit is contained in:
parent
44b762cf08
commit
ad6e4b838a
|
|
@ -1,12 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using Microsoft.AspNet.Http;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Hosting
|
|
||||||
{
|
|
||||||
public interface IHttpContextAccessor
|
|
||||||
{
|
|
||||||
HttpContext HttpContext { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
#if DNX451
|
|
||||||
using System.Runtime.Remoting.Messaging;
|
|
||||||
using System.Runtime.Remoting;
|
|
||||||
#elif DNXCORE50
|
|
||||||
using System.Threading;
|
|
||||||
#endif
|
|
||||||
using Microsoft.AspNet.Http;
|
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Hosting
|
|
||||||
{
|
|
||||||
public class HttpContextAccessor : IHttpContextAccessor
|
|
||||||
{
|
|
||||||
#if DNX451
|
|
||||||
private const string LogicalDataKey = "__HttpContext_Current__";
|
|
||||||
|
|
||||||
public HttpContext HttpContext
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var handle = CallContext.LogicalGetData(LogicalDataKey) as ObjectHandle;
|
|
||||||
return handle != null ? handle.Unwrap() as HttpContext : null;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
CallContext.LogicalSetData(LogicalDataKey, new ObjectHandle(value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif DNXCORE50
|
|
||||||
private AsyncLocal<HttpContext> _httpContextCurrent = new AsyncLocal<HttpContext>();
|
|
||||||
public HttpContext HttpContext
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _httpContextCurrent.Value;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_httpContextCurrent.Value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -7,6 +7,8 @@ using Microsoft.AspNet.Hosting.Builder;
|
||||||
using Microsoft.AspNet.Hosting.Internal;
|
using Microsoft.AspNet.Hosting.Internal;
|
||||||
using Microsoft.AspNet.Hosting.Server;
|
using Microsoft.AspNet.Hosting.Server;
|
||||||
using Microsoft.AspNet.Hosting.Startup;
|
using Microsoft.AspNet.Hosting.Startup;
|
||||||
|
using Microsoft.AspNet.Http;
|
||||||
|
using Microsoft.AspNet.Http.Internal;
|
||||||
using Microsoft.Dnx.Runtime;
|
using Microsoft.Dnx.Runtime;
|
||||||
using Microsoft.Framework.Configuration;
|
using Microsoft.Framework.Configuration;
|
||||||
using Microsoft.Framework.DependencyInjection;
|
using Microsoft.Framework.DependencyInjection;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue