是的,這是可能的dynamiclly使用RedirectToIdentityProvider
改變回覆URL。您可以參考下面的代碼示例:
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
RedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
},
RedirectToIdentityProvider=(context)=>
{
context.ProtocolMessage.RedirectUri = "";
return Task.FromResult(0);
}
}
});
但是,如果應用程序已經部署到Web服務器上,更改重定向URL到本地主機可能無法按你的預期,因爲有對網絡兩種不同的應用程序服務器應用運行。
什麼這意味着是,你會手動將重定向URI請求URI?聽起來像是唯一的方法.. – juunas
謝謝你的回報,但我不明白爲什麼要更改Azure AD中的重定向URL。它不是自動的? – Vilela
您在Azure門戶上註冊應用程序的重定向URL與您在請求中傳遞的重定向URL之間有所不同。 Azure廣告將根據門戶上的值寄存器驗證傳遞的重定向URL。如果該值被驗證,則Azure AD會將此URL返回給客戶端。如果問題沒有解決,請隨時通知我。 –