In the controller I\'m currently using Context.Session.GetString(*KEY*);
I have a class that needs to read from a few values stored in the session
I
HttpContext.Current
doesn't exist anymore in ASP.NET 5, but there's a new IHttpContextAccessor
that you can inject in your dependencies and use to retrieve the current HttpContext
: https://github.com/aspnet/Hosting/blob/dev/src/Microsoft.AspNet.Hosting.Abstractions/IHttpContextAccessor.cs
public class MyComponent : IMyComponent {
private readonly IHttpContextAccessor contextAccessor;
public MyComponent(IHttpContextAccessor contextAccessor) {
this.contextAccessor = contextAccessor;
}
public string GetDataFromSession() {
return contextAccessor.HttpContext.Session.GetString(*KEY*);
}
}