我喜欢我的ASP.NET MVC 4项目,我的Global.asax.cs页显示了

 WebApiConfig.Register(GlobalConfiguration.Configuration);

The name 'GlobalConfiguration' does not exist in the current context

我做了很多控制器和视图,所有的...如何解决此问题并恢复我的项目?

以下是我的上下文代码的睡觉

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace .....
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
    }
}

推荐答案

确保引用了程序集System.Web.Http.WebHost.dll.这就是全球配置的所在.

Asp.net相关问答推荐

包含Include的低速EF核心查询

ASP.NET Core 延迟加载始终返回 null

Razor 页面客户端站点验证不起作用

在正则表达式中允许 -(破折号)

如何在 GridView 单元格中的(即
)中呈现解码的 HTML

asp.net - 会话 - 多个浏览器选项卡 - 不同的会话?

解析器错误消息:文件/TestSite/Default.aspx.cs不存在

我应该如何在类和应用层之间传递数据?

Web Api 参数始终为空

如何设置 CSS 切换器

ASP.NET RadioButton 与名称(组名)混淆

如何获取 ASP.NET 应用程序的完整虚拟路径

为应用程序池Classic .NET AppPool提供服务的进程与 Windows 进程激活服务发生了致命的通信错误

在 Android/Java 和 C# 中计算 SHA256 哈希

在 JavaScript 中获取当前会话值?

如何在 .NET Core 中实现 DbContext 连接字符串?

简单的 LINQ 和列表错误:WhereListIterator`1[Task]' to type 'System.Collections.Generic.List`1[Task]'

IIS url 重写角色,除了一些 url

x-powered by是什么意思?

如何在 ASP.NET 响应中传递大文件?