Luis Teijon Luis Teijon - 21 days ago 10
C# Question

HttpConfiguration does not contain a definition for SuppressDefaultHostAuthentication

I created an ASP.NET-WebApi application and I've got this error:

HttpConfiguration does not contain a definition for SuppressDefaultHostAuthentication ...

The code was auto-generated, I think it has to be a reference, but couldn't find that reference.

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 }
);
}
}

Answer

Try to add the nugget package : Microsoft ASP.NET Web API 2.2 OWIN

https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin/