我尝试使用单个身份验证将ASP.NET单页应用程序连接到ASP.NET Web API 2.0服务器。我能够使用提琴手和原始的HTTP请求的服务器进行身份验证如图所示在下面的教程:未能将ASP.NET Web客户端连接到Web API 2.0个人帐户身份验证服务器
Individual Accounts in Web API
我的问题是我怎么随便点了独立的单页客户样品到Web API服务?它只是一个简单的配置文件或连接字符串的变化吗?
令人惊讶的我无法找到如何做到这一点可能在网络上那么多的信息,因为它看起来很简单,我只是失去了一些东西,因为我是新来ASP.NET
更新:
我基本上希望这指向一个不同的Web API 2.0服务器:
static Startup()
{
PublicClientId = "self";
UserManagerFactory =() => new UserManager<IdentityUser>(new UserStore<IdentityUser>());
OAuthOptions = new OAuthAuthorizationServerOptions
{
TokenEndpointPath = new PathString("/Token"),
Provider = new ApplicationOAuthProvider(PublicClientId, UserManagerFactory),
AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"),
AccessTokenExpireTimeSpan = TimeSpan.FromDays(14),
AllowInsecureHttp = true
};
}
public void ConfigureAuth(IAppBuilder app)
{
// Enable the application to use a cookie to store information for the signed in user
// and to use a cookie to temporarily store information about a user logging in with a third party login provider
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Enable the application to use bearer tokens to authenticate users
app.UseOAuthBearerTokens(OAuthOptions);
....
}
,目前指向应用程序的根,但在Web API 2.0服务器实际上是另一个ASP.NE T应用程序在其他地方运行。
如果我正确地理解了你,你问你如何在你的asp.net应用程序中使用web api 2.0服务? – VsMaX
是的,但是来自Visual Studio的“ASP.NET单页应用程序”模板。这意味着我在模板中的哪个位置设置客户端Uri,我不想重写模板生成的所有代码只是想使用它来挂接Web API 2.0个人身份验证。 –