GlobalConfiguration does not contain a definition for Configure

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-04 02:14:05
  1. Open the Package Manager Console for the Project with the error.
  2. Type in Install-Package Microsoft.AspNet.WebApi.WebHost and hit Enter.
  3. Rebuild your Project.

It looks like there is some sort of namespace conflict with the generated code. I'm fairly weary about this change, but everything has worked thus far.

Apparently GlobalConfiguration refers to MyModel.GlobalConfiguration.

However it's really looking for System.Web.Http.GlobalConfiguration

I switched this and all is working. What a hassle

protected void Application_Start()
{
    AreaRegistration.RegisterAllAreas();
    System.Web.Http.GlobalConfiguration.Configure(WebApiConfig.Register);
    FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
    RouteConfig.RegisterRoutes(RouteTable.Routes);
    BundleConfig.RegisterBundles(BundleTable.Bundles);
}

1 - Make sure the files in your Team Explorer, if perform checkin;

2 - Check for old files in "packages" concerning the dll WebAPI such as the folder "Microsoft.AspNet.WebApi.WebHost.5.2.3" folder, if there are clear;

3 - After leaving everything clean install the project;

Good luck!!!!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!