我試圖使用Azure AD B2C將身份驗證添加到Web表單應用程序。不幸的是,除了this web forms tutorial之外,我發現每個教程都是針對MVC的。使用該教程,我已將此代碼添加到我的startup.auth.cs中:使用B2C的Web表單身份驗證
public partial class Startup {
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301883
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = "my-client-id",
Authority = "https://login.microsoftonline.com/my-tenant"
});
}
}
而且工作正常。然而,我需要註冊功能以及登錄,但我無法弄清楚如何去做,因爲我發現的所有內容都是針對MVC的,我不確定如何將其轉換爲我需要的。我已經嘗試添加如下代碼:
app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(_SignUpPolicyId));
app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(_ProfilePolicyId));
app.UseOpenIdConnectAuthentication(CreateOptionsFromPolicy(_SignInPolicyId));
以及創建登錄頁面上的三個按鈕,但點擊它們只是給出了一個404錯誤,並沒有額外的信息,所以我不知道如何做這項工作,或者即使我朝着正確的方向前進。我以前從未與B2C合作過,所以如果任何人有任何建議/已經爲Web表單做過這樣的事情,我會非常感激一些提示或示例代碼。
我最終將項目切換到MVC,因爲al我們其餘的網站都是用MVC完成的,所以我們決定這個應該也是。所以,我沒有真正檢查你的答案,因爲它不再相關,但我感謝你花時間,所以我會接受,以便問題得到解決。謝謝! – issharp
我很欣賞評論 – Danrex