我嘗試使用單個身份驗證將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個人身份驗證。 –