这个问题可能是由应用程序的配置出现问题所引起的。为了解决这个问题,您可以尝试以下步骤:
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
})
.AddCookie()
.AddOpenIdConnect(options =>
{
options.Authority = "https://yourIdentityServerURL.com";
options.ClientId = "yourClientId";
options.SaveTokens = true;
options.ResponseType = "code";
});
var supportedCultures = new[]
{
new CultureInfo("en-US"),
new CultureInfo("fr-FR"),
new CultureInfo("de-DE"),
new CultureInfo("ja-JP"),
};
app.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-US"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
services.Configure(options =>
{
options.MinimumSameSitePolicy = SameSiteMode.Unspecified;
options.CheckConsentNeeded = context => true;
options.HttpOnly = HttpOnlyPolicy.None;
options.Secure = CookieSecurePolicy.None;
options.SameSite = SameSiteMode.None;
});
尝试上述方法可能可以解决ASP.NET Core 6.0 Web应用程序在身份验证期间无法重定向到Identity Server的问题。