上下文
我在 Controller 中。
我使用命名空间 System.Web :
using System.Web;
当我调用 HttpContext.Current 时,VS 提醒我 Current 未在 HttpContextBase 中定义:
HttpContext.Current.Session["currentUser"];
如果我在 HttpContext.Current 之前指定 System.Web,它会起作用:
System.Web.HttpContext.Current.Session["currentUser"];
问题
为什么要在 HttpContext.Current 之前注明 System.Web?
请您参考如下方法:
你有命名空间冲突,使用这个:
使用 HttpContext = System.Web.HttpContext;
