我有Web Api。它在我的本地计算机上运行良好,但是当我在我的服务器/主机上发布它时。只有Url才能请求OAuth令牌返回"未找到与请求匹配的HTTP资源"。所有其他控制器工作正常。
为什么它只在生产中发生?
我的Startup.cs
using System;
using System.Web.Http;
using Microsoft.Owin;
using Microsoft.Owin.Security.OAuth;
using Owin;
[assembly: OwinStartup(typeof(Api.Startup))]
namespace Api
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
var config = new HttpConfiguration();
ConfigureOAuth(app);
WebApiConfig.Register(config);
app.UseWebApi(config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
app.UseWebApi(config);
}
public void ConfigureOAuth(IAppBuilder app)
{
var oAuthServerOptions = new OAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = new PathString("/api/v1/oauth/token"), //TODO: FROM WEB CONFIG
AccessTokenExpireTimeSpan = TimeSpan.FromDays(1), //TODO: FROM WEB CONFIG
Provider = new AuthorizationProvider()
};
app.UseOAuthAuthorizationServer(oAuthServerOptions);
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());
}
}
}
最好的问候