找不到HttpContextBase名称空间

ABE*_*ILA 9 c# asp.net-core-mvc asp.net-core

   public string GetCartId(HttpContextBase context)
    {
        if (context.Session[CartSessionKey] == null)
        {
            if (!string.IsNullOrWhiteSpace(context.User.Identity.Name))
            {
                context.Session[CartSessionKey] =
                    context.User.Identity.Name;
            }
            else
            {
                // Generate a new random GUID using System.Guid class
                Guid tempCartId = Guid.NewGuid();
                // Send tempCartId back to client as a cookie
                context.Session[CartSessionKey] = tempCartId.ToString();
            }
        }
        return context.Session[CartSessionKey].ToString();
Run Code Online (Sandbox Code Playgroud)

有关在asp.net核心中使用HttpContextBase的任何帮助吗?上面是我的示例代码我正在努力创建一个购物车.

Tse*_*eng 25

HttpContextBaseASP.NET Core中没有.HttpContext已经是一个抽象类(见这里),它在DefaultHttpContext(参见GitHub)中实现.只是用HttpContext.