2016-11-19 36 views
6

Tôi tạo ra một ứng dụng ASP.NET-WebAPI và tôi đã có lỗi này:HttpConfiguration không chứa một định nghĩa cho SuppressDefaultHostAuthentication

HttpConfiguration does not contain a definition for SuppressDefaultHostAuthentication

Mã này được tự động tạo ra, tôi nghĩ rằng nó có phải là một tài liệu tham khảo , nhưng không thể tìm thấy tham chiếu đó.

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

Trả lời

10

Cố gắng thêm gói nugget: Microsoft ASP.NET Web API 2.2 OWIN

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

+0

Tôi đã đã cài đặt gói này. –

+0

Tôi không bao giờ nghĩ rằng nó đã làm với gói OWIN. Tôi đã gỡ cài đặt và cài đặt lại. Mọi thứ đã hoạt động. –

Các vấn đề liên quan