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的任何帮助吗?上面是我的示例代码我正在努力创建一个购物车.
| 归档时间: |
|
| 查看次数: |
9369 次 |
| 最近记录: |