Net Core:'HttpContext' 不包含 'Current'` 的定义

Net Core: 'HttpContext' does not contain a definition for 'Current'`

我正在将项目从 .Net 4.6.2 迁移到 .Net Core 2.0。 我在下面收到错误。 'HttpContext' does not contain a definition for 'Current'

我该如何解决?

原码:

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 &&

错误代码:

'HttpContext' does not contain a definition for 'Current'

尝试的代码:

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

错误:

非静态字段、方法或 属性 'HttpContext.Session'

需要对象引用

也许你可以使用 HttpContext.User.Identity.IsAuthenticated