Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Visual Studio[ASP.NET MVC]无法识别HttpContext.Current_C#_Asp.net_Asp.net Mvc_Httpcontext - Fatal编程技术网

C# Visual Studio[ASP.NET MVC]无法识别HttpContext.Current

C# Visual Studio[ASP.NET MVC]无法识别HttpContext.Current,c#,asp.net,asp.net-mvc,httpcontext,C#,Asp.net,Asp.net Mvc,Httpcontext,我正在做一个ASP.NET MVC项目,完全是在控制器中的无效方法,我需要使用HttpContext.Current.Request.Cookies,但是Visual Studio将Current识别为错误,并且在Intilisense中未显示(Current) 这是我的方法: public void User_Access_Validation() { var T_8 = HttpContext.Current.Request.Cookies["T_8"];

我正在做一个ASP.NET MVC项目,完全是在
控制器
中的
无效方法
,我需要使用
HttpContext.Current.Request.Cookies
,但是Visual Studio
Current
识别为错误,并且在Intilisense中未显示(
Current

这是我的方法:

public void User_Access_Validation()
{

            var T_8 = HttpContext.Current.Request.Cookies["T_8"];
            var T_5 = HttpContext.Current.Request.Cookies["T_5"];
            var T_T = HttpContext.Current.Request.Cookies["T_T"];

            HttpContext.Current.Request.Cookie

            if (T_8 == null || T_5 == null || T_T == null)
            {
                response.Redirect("/Login");
            }
}

因此,请提供任何帮助?

正如他在回答中提到的,在您的案例中需要使用
当前
时,您需要使用
System.Web.HttpContext.Current.Cookies[“xxx”]

您是否添加了
使用System.Web在类中?是的,我添加了它方法可能在控制器类中,但不清楚该方法是否从控制器操作调用,其中应存在HttpContext-您是否尝试在正在访问的控制器操作中设置断点,并检查HttpContext.Current是否也为空?您是否尝试过
System.Web.HttpContext.Current
?您使用的是.NET内核而不是.NET Framework?