ASP.NET Web API-OWIN-TokenEndPointPath在IIS中不起作用 [英] ASP.NET Web API - OWIN - TokenEndPointPath not working in IIS
问题描述
在startup.cs中有以下代码.设置TokenEndpointPath在IIS Express中以及将Web API项目部署到IIS中网站的根目录时都可以完美地工作.但是,如果我在IIS中的嵌套应用程序(即网站中的应用程序)中托管,则对令牌终结点的调用将导致404.是否有办法将TokenEndpointPath基于实际的IIS结构而不是根结构,因此在这里吗?现在:
I have the following code in my startup.cs. Setting up the TokenEndpointPath works perfectly in IIS Express and when the Web API project is deployed to the root of a website in IIS. However, if I host in a nested application (i.e. an application within a website) in IIS calls to the token endpoint result in a 404. Is there a way to base the TokenEndpointPath off of the actual IIS structure instead of the root, as it does here? Right now:
这有效
这不是
http://server:80/app/api/token
var request = HttpContext.Current.Request;
app.UseOAuthAuthorizationServer(newOAuthAuthorizationServerOptions
{
AllowInsecureHttp = true,
TokenEndpointPath = newPathString("/api/token"),
AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(oauthTokenTimeoutInMinutes),
Provider = new Provider.ActiveDirectoryAuthorizationServerProvider()
});
推荐答案
如前所述,我已经通过设置TokenEndpointPath = new PathString("/api/Token")
测试了您的问题.首先,我的connectionString
如下所示:
As commented, I have tested your issue by setting TokenEndpointPath = new PathString("/api/Token")
. At first, my connectionString
looks like the following:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-WebApi-20150818041808.mdf;Initial Catalog=aspnet-WebApi-20150818041808;Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
将项目发布到本地IIS(7.5)后,将POST请求发送到
After publishing the project to Local IIS (7.5), getting 500 error response when sending POST request to
然后我像下面这样更新了connectionString
:
Then I updated connectionString
like the following:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=192.168.1.247;Initial Catalog=MyDB;Integrated Security=True;MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
它的工作原理类似于以下屏幕截图:
It works like the following screenshot:
这篇关于ASP.NET Web API-OWIN-TokenEndPointPath在IIS中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!