HttpContextBase namespace could not be Found

I had to modify like below

public string GetCartId(HttpContext context)
{
    if (context.Session.GetString(CartSessionKey) == null)
    {
        if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
        {
            context.Session.SetString(CartSessionKey, context.User.Identity.Name);
        }
        else
        {
            var tempCartId = Guid.NewGuid();
            context.Session.SetString(CartSessionKey, tempCartId.ToString());
        }
    }

    return context.Session.GetString(CartSessionKey);
}

It may help someone :)


There is no HttpContextBase in ASP.NET Core. HttpContext is already an abstract class (see here) which is implemented in DefaultHttpContext (see GitHub). Just use HttpContext.