2016-11-19 2 views
0

ich eine ASP.NET-WebAPI Anwendung erstellt, und ich habe diesen Fehler habe:Der Typ oder Namespace-Namen HostAuthenticationFilter nicht gefunden

Der Typ oder Namespace-Namen HostAuthenticationFilter konnte nicht gefunden werden ...

Der Code wurde automatisch generiert, ich denke, es muss eine Referenz sein, konnte aber diese Referenz nicht finden.

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

Antwort

4

Haben installieren Sie das Nugget-Paket Microsoft ASP.NET Web API 2.2 OWIN:

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

+0

Ja, ich habe es installiert ist. –

+0

Es war das Paket Microsoft.AspNet.WebApi.Owin, genau wie du gesagt hast. Ich habe es deinstalliert und es erneut installiert. Alles hat funktioniert. –

Verwandte Themen