我创建了一个ASP.NET-WebApi应用程序,我遇到了这个错误:
HttpConfiguration不包含SuppressDefaultHostAuthentication的定义
代码是自动生成的,我认为它必须是参考,但无法找到该参考。
using System.Web.Http;
using Microsoft.Owin.Security.OAuth;
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
// Configure Web API to use only bearer token authentication.
config.SuppressDefaultHostAuthentication();
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
答案 0 :(得分:19)
尝试添加nugget包:Microsoft ASP.NET Web API 2.2 OWIN
https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin/