I am migrating a project from .Net 4.6.2 into .Net Core 2.0.
I am receiving error below. 'HttpContext' does not contain a definition for 'Current'
How would I resolve this?
Original Code:
public class CustomerAuthorize : AuthorizeAttribute
{
/// Gets or sets a session variable indicates that the logged in user has been already authorized to login to the system.
private bool IsAuthorized
{
get
{
if (HttpContext.Current.Session["IsAuthorized"] != null &&
Error Code:
'HttpContext' does not contain a definition for 'Current'
Attempted Code:
public class CustomerAuthorize : AuthorizeAttribute
{
// Gets or sets a session variable indicates that the logged in user has been already authorized to login to the system.
const string IsAuthorized2 = "IsAuthorized";
private bool IsAuthorized
{
get
{
if (HttpContext.Session.GetString(IsAuthorized2) != null
Error:
An object reference is required for the non-static field, method, or property 'HttpContext.Session'