[ERROR]’System.Web.Http.GlobalConfiguration’ does not contain a definition for ‘Configure’

[ERROR]'System.Web.Http.GlobalConfiguration' does not contain a definition for 'Configure'


在VS.NET 2013中,新建MVC项目,并选取Web API后,会在Global.asax.cs中的

GlobalConfiguration.Configure(WebApiConfig.Register);

出现以下的错误,

'System.Web.Http.GlobalConfiguration' does not contain a definition for 'Configure'

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

image

解决方式可参考“Solving System.Web.Http.GlobalConfiguration' does not contain a definition for 'Configure”,

开启 Package Manager Console ,

然后输入 Install-Package Microsoft.AspNet.WebApi.WebHost 按下 Enter

image

再重新建置就可以了!

参考数据

Solving System.Web.Http.GlobalConfiguration' does not contain a definition for 'Configure