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();
asp.netコアのHttpContextBaseでの回避に関する助け?私のサンプルコードはショッピングカートの作成に取り組んでいます。HttpContextBase名前空間を見つけることができませんでした
あなたはHttpContextBase abstractContext =新しいSystem.Web.HttpContextWrapper(コンテキスト)を使用することができます。 Tomato32 @ – Tomato32
ASP.NETコアには、 'System.Web'はもうありません – Tseng
あなたは、コントローラのこの外側をやっていますか? – Coemgen