首页 > 解决方案 > 未找到 Azure 应用服务 ASP.NET Web API OWIN OAuth 路径

问题描述

我在 Azure 应用服务上托管一个 ASP.NET Web API。Web API 具有带有端点的 OWIN OAuth 身份验证api/token。该 api 在 IIS 环境中运行良好。由于某种原因,当托管在 Azure 应用服务上时,令牌端点无法正常工作并导致以下错误:the controller for path 'api/token' was not found or does not implement icontroller.

owin 启动类被调用。启动类如下所示:

 OAuthBearerAuthenticationOptions OAuthBearerOptions = new OAuthBearerAuthenticationOptions();
        OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions
        {
            TokenEndpointPath = new PathString("/api/token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(authenticationElement.AccessTokenExpireTimeSpan),
            Provider = provider,
            RefreshTokenProvider = new GrcApiRefreshTokenProvider(),
            AllowInsecureHttp = authenticationElement.AllowInsecureHttp
        };

        // Token Generation
        app.UseOAuthAuthorizationServer(OAuthServerOptions);

        //Token Consumption
        app.UseOAuthBearerAuthentication(OAuthBearerOptions);

标签: c#azureasp.net-web-apiazure-web-app-serviceowin

解决方案


我的解决方案是使用https而不是http. 尽管 owin 中间件被设置为允许不安全。


推荐阅读