gpt4 book ai didi

c# - 为什么要在 HttpContext.Current 之前指明 System.Web?

转载 作者:太空宇宙 更新时间:2023-11-03 19:21:56 25 4
gpt4 key购买 nike

上下文

我在 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;

关于c# - 为什么要在 HttpContext.Current 之前指明 System.Web?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11627477/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com