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

问题描述 投票:0回答:1

我正在ASP.NET MVC项目上,正好在void method中的Controller上工作,我需要使用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");
            }
}

所以请您帮忙吗?

我正在一个ASP.NET MVC项目上,正好在Controller中的void方法上工作,我需要使用HttpContext.Current.Request.Cookies,但是Visual Studio将Current识别为错误,因此未显示(.. 。

c# asp.net asp.net-mvc httpcontext
1个回答
1
投票

正如vivek nuna在他的回答中提到的,需要根据情况使用System.Web.HttpContext.Current.Cookies["xxx"]时,需要使用Current

© www.soinside.com 2019 - 2024. All rights reserved.