Rename IHttpContextAccessor.Value to IHttpContextAccessor.HttpContext
Fixes: https://github.com/aspnet/Hosting/issues/160
This commit is contained in:
parent
16c8d51d0b
commit
d6535eeba0
|
|
@ -17,7 +17,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
#if ASPNET50
|
#if ASPNET50
|
||||||
private const string LogicalDataKey = "__HttpContext_Current__";
|
private const string LogicalDataKey = "__HttpContext_Current__";
|
||||||
|
|
||||||
public HttpContext Value
|
public HttpContext HttpContext
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Hosting
|
||||||
|
|
||||||
#elif ASPNETCORE50
|
#elif ASPNETCORE50
|
||||||
private AsyncLocal<HttpContext> _httpContextCurrent = new AsyncLocal<HttpContext>();
|
private AsyncLocal<HttpContext> _httpContextCurrent = new AsyncLocal<HttpContext>();
|
||||||
public HttpContext Value
|
public HttpContext HttpContext
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,6 @@ namespace Microsoft.AspNet.Hosting
|
||||||
{
|
{
|
||||||
public interface IHttpContextAccessor
|
public interface IHttpContextAccessor
|
||||||
{
|
{
|
||||||
HttpContext Value { get; set; }
|
HttpContext HttpContext { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ namespace Microsoft.AspNet.Hosting.Internal
|
||||||
public Task Invoke(IFeatureCollection featureCollection)
|
public Task Invoke(IFeatureCollection featureCollection)
|
||||||
{
|
{
|
||||||
var httpContext = _httpContextFactory.CreateHttpContext(featureCollection);
|
var httpContext = _httpContextFactory.CreateHttpContext(featureCollection);
|
||||||
_contextAccessor.Value = httpContext;
|
_contextAccessor.HttpContext = httpContext;
|
||||||
return _requestDelegate(httpContext);
|
return _requestDelegate(httpContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ namespace Microsoft.AspNet.TestHost
|
||||||
app.Run(context =>
|
app.Run(context =>
|
||||||
{
|
{
|
||||||
var accessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
|
var accessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
|
||||||
return context.Response.WriteAsync("HasContext:"+(accessor.Value != null));
|
return context.Response.WriteAsync("HasContext:"+(accessor.HttpContext != null));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue