Итак, я пытаюсь создать портал для проекта и использовать B2 C в качестве системы входа в систему, поскольку это проще, чем создать собственную систему и постоянно работать с SQL на ней.
Я использую этот учебник как способ узнать, как его сделать.
Теперь, когда я пытаюсь запустить его, я получаю сообщение об ошибке в моем Startup.auth. cs class.
Это код, который я использую:
Startup.Auth.cs
// public partial class Startup
{
// Calling the key values from the web.config section
private static string clientId = ConfigurationManager.AppSettings["ida:ClientId"];
private static string tenant = ConfigurationManager.AppSettings["ida:Tenant"];
private static string aadInstance = ConfigurationManager.AppSettings["ida:AadInstance"];
private static string redirectUri = ConfigurationManager.AppSettings["ida:RedirectUri"];
// Concatenate the aadInstance, tenant to forn authority value
private string authority = string.Format(CultureInfo.InvariantCulture, aadInstance, tenant);
/*
* Configure the method
* The method is used to build an authentication system that lets me be able to log in and out with B2C
*/
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = redirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = (context) =>
{
context.HandleResponse();
context.OwinContext.Response.Redirect("/Home/Index");
return Task.FromResult(0);
}
}
});
}
Startup.cs:
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
И в своем web.config я добавил TenantId , ClientId, ClientSecret, AadInstance, REdirectUri и значения пароля для входа в систему / регистрации и сброса пароля в
генерирует эту ошибку, когда я пытаюсь запустить ее локально:
"System.FormatException: 'Индекс (на основе нуля) должен быть больше или равен нулю и меньше размера списка аргументов.' "