Thứ nhất, mọi thứ hoạt động khi tôi chạy nó từ Visual Studio sử dụng iis express
.Owin OAuth localhost/Token trả lại 404
Tôi có Api Web Asp.Net đang chạy Owin OAuth. Đây là phần cấu hình của lớp Startup
tôi:
private static void ConfigureAuth(IAppBuilder app)
{
var oAuthOptions = new OAuthAuthorizationServerOptions
{
#if DEBUG
AllowInsecureHttp = true,
#endif
TokenEndpointPath = new PathString("/Token"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(30),
Provider = new ApplicationOAuthProvider()
};
app.UseOAuthAuthorizationServer(oAuthOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
}
Đây là Register
phần của WebApiConfig.cs
public static void Register(HttpConfiguration config)
{
// Web API configuration and services
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter(OAuthDefaults.AuthenticationType));
var cors = new EnableCorsAttribute("*", "*", "*");
config.EnableCors(cors);
// Web API routes
config.MapHttpAttributeRoutes();
// OData
var builder = new ODataConventionModelBuilder();
builder.EntitySet<Employee>("Employee");
config.MapODataServiceRoute(
routeName: "ODataRoute",
routePrefix: "odata/",
model: builder.GetEdmModel()
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
tôi đã triển khai ứng dụng này trên IIS phiên bản 8.5 * và tôi tất cả mọi thứ công trình trừ localhost/Token
endpoint. . Nó là một dự án MVC + Web Api kết hợp.
Tôi đang sử dụng hồ bơi ứng dụng .NET v4.5 (.NET CLR Phiên bản: 4.0) với chế độ đường ống tích hợp và Microsoft.Owin.Host.SystemWeb.dll
có trong thư mục bin.
Tại sao tôi nhận được 404 khi tôi thực hiện yêu cầu đến điểm cuối mã thông báo?
Bạn đã đặt 'runAllManagedModulesForAllRequests' thành true như trong [câu trả lời SO này] (http://stackoverflow.com/questions/24101432/configure-an-owin-static-file-server-at-a-specific-route -tiếp đầu ngữ)? –
Có, nó không hoạt động. –
Mọi cập nhật tại đây? –