无法访问HttpContext.Current [英] Can't access to HttpContext.Current
问题描述
我无法使用C#4.5在我的项目MVC4上访问HttpContext.Current
I can't access to HttpContext.Current on my project MVC4 with C#4.5
我在项目中添加了对System.Web的引用,并在控制器页面上添加了using指令...
I've added my reference to System.Web in my project and added the using instruction on my controller page...
但是我只能访问currentHandler ...
But I can access currentHandler only...
var context = HttpContext.CurrentHandler; //Current
HttpContext.Current
在C#4.5上已弃用吗?
Is HttpContext.Current
deprecated on C#4.5 ?
我查看了此帮助页面: http://msdn.microsoft.com/zh-CN/library/system.web.httpcontext.aspx
I've looked this help page : http://msdn.microsoft.com/en-us/library/system.web.httpcontext.aspx
推荐答案
您是否已将System.Web
程序集包含在应用程序中?
Have you included the System.Web
assembly in the application?
using System.Web;
如果没有,请尝试指定System.Web
命名空间,例如:
If not, try specifying the System.Web
namespace, for example:
System.Web.HttpContext.Current
这篇关于无法访问HttpContext.Current的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!