5
目前我的身份服務器運行完美,但我想在其上添加一個API,以便通過Web前端進行一些數據庫配置更改。文檔中的示例顯示瞭如何使用MVC執行此操作,但不顯示WebAPI。如何在同一個項目中運行IdentityServer和WebAPI
的Startup.Configuration方法是這樣的:
app.UseIdentityServer(new IdentityServerOptions{ ... });
...
app.Map("/api", apiApp =>
{
apiApp.UseIdentityServerBearerTokenAuthentication(new IdentityServerBearerTokenAuthenticationOptions
{
Authority = "https://localhost:44300", // URL of identity server
});
});
然而,當app.Map
被調用,它拋出一個錯誤,因爲它無法到達服務器的身份,大概是因爲它尚未開始。我怎樣才能讓他們一起合作?