Luis Teijon Luis Teijon - 20 days ago 9
C# Question

The type or namespace name HostAuthenticationFilter could not be found

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

The type or namespace name HostAuthenticationFilter could not be found...

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.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}

Answer

Did you install the Nugget package Microsoft ASP.NET Web API 2.2 OWIN :

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