【发布时间】:2015-08-14 08:10:59
【问题描述】:
首先,当我使用 iis express 从 Visual Studio 运行它时,一切正常。
我有一个运行 Owin OAuth 的 Asp.Net Web Api。这是我Startup类的配置部分:
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());
}
这是我的WebApiConfig.cs 的Register 部分
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 }
);
}
我已经在 IIS 版本 8.5.* 上部署了这个应用程序,除了localhost/Token 端点外,一切正常。它是一个结合 MVC + Web Api 的项目。
我正在使用具有集成管道模式的 .NET v4.5 应用程序池(.NET CLR 版本:4.0),并且 Microsoft.Owin.Host.SystemWeb.dll 存在于 bin 文件夹中。
为什么我向 Token 端点发出请求时得到 404?
【问题讨论】:
-
您是否像 this SO answer 一样将
runAllManagedModulesForAllRequests设置为 true? -
是的,它也不起作用。
-
我会尽快发布更新
-
找到任何解决方案?...请更新我们
-
尝试在 web.config 中添加