【发布时间】:2017-11-24 08:29:12
【问题描述】:
我一直在关注 Microsoft 文档,尝试使用此行设置会话
HttpContext.Session.SetString(SessionKeyName, "Rick");
从页面 https://docs.microsoft.com/en-us/aspnet/core/fundamentals/app-state?tabs=aspnetcore2x
但它给出了错误
'ISession' does not contain a definition for 'SetString'
有一个Set 选项,但需要一个字节。
知道我做错了什么以及为什么我使用了错误的HttpContext.Session?
【问题讨论】:
-
显然你忘了使用:
using Microsoft.AspNetCore.Http;
标签: asp.net-core-mvc