无法访问 HttpContext.Current

编程入门 行业动态 更新时间:2024-10-17 09:41:25
本文介绍了无法访问 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 的引用,并在我的控制器页面上添加了使用说明...

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 ?

我看过这个帮助页面:msdn.microsoft/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

本文发布于:2023-11-13 15:03:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法访问   HttpContext   Current

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!