Microsoft.AspNetCore.Identity.SignInResult loSignInResult = await base._oLoginManager.PasswordSignInAsync(loUser.UserName, lsPassword, true, false);
Это строка, которая вызывает сообщение 502 Bad Gateway.
Пожалуйста, ознакомьтесь с программой запуска ниже (_bStaging имеет значение false, когда возникает эта ошибка), я попытался изменить порядок кода без успеха.Эта ошибка начала появляться на днях без существенного изменения кода.На сервере не было внесено никаких изменений, и только у меня есть доступ .:
public void ConfigureServices(IServiceCollection loServices)
{
try
{
if (!this._bIsStaging)
{
loServices.Configure<MvcOptions>(options =>
{
options.Filters.Add(new RequireHttpsAttribute());
});
}
loServices.AddSession();
Heron.Data.Classes.ConnectionStrings._sHeronConnectionString = this._oConfiguration.GetConnectionString(this.GetConnectionStringName("Heron"));
Heron.Data.Classes.ConnectionStrings._sIdentityConnectionString = this._oConfiguration.GetConnectionString(this.GetConnectionStringName("Identity"));
loServices.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
loServices.AddDbContext<Heron.Data.DB.HeronContext>(O => O.UseSqlServer(Heron.Data.Classes.ConnectionStrings._sHeronConnectionString));
loServices.AddScoped<DbContext>(sp => sp.GetService<Heron.Data.DB.HeronContext>());
loServices.AddDbContext<Heron.Data.DB.Extensions.IdentityExtend.DbContext>(O => O.UseSqlServer(Heron.Data.Classes.ConnectionStrings._sIdentityConnectionString));
loServices.AddScoped<DbContext>(sp => sp.GetService<Heron.Data.DB.Extensions.IdentityExtend.DbContext>());
loServices.AddIdentity<Heron.Data.DB.Extensions.IdentityExtend.User, Heron.Data.DB.Extensions.IdentityExtend.Role>(opts =>
{
opts.Lockout.DefaultLockoutTimeSpan = new TimeSpan(0, 0, Heron.Library.Classes.Constants._nDefaultLockoutTime, 0);
opts.Lockout.MaxFailedAccessAttempts = Heron.Library.Classes.Constants._nMaxFailedAccessAttempts;
opts.Lockout.AllowedForNewUsers = true;
opts.Password.RequireDigit = true;
opts.Password.RequireLowercase = true;
opts.Password.RequireUppercase = true;
opts.Password.RequireNonAlphanumeric = true;
opts.Password.RequiredLength = Heron.Library.Classes.Constants._nMinRequiredDigitsPassword;
}).AddEntityFrameworkStores<Heron.Data.DB.Extensions.IdentityExtend.DbContext>().AddDefaultTokenProviders().AddUserManager<UserManager<Heron.Data.DB.Extensions.IdentityExtend.User>>();
loServices.AddScoped<SignInManager<Heron.Data.DB.Extensions.IdentityExtend.User>>();
loServices.AddScoped<UserManager<Heron.Data.DB.Extensions.IdentityExtend.User>>();
loServices.AddScoped<RoleManager<Heron.Data.DB.Extensions.IdentityExtend.Role>>();
loServices.ConfigureApplicationCookie(options =>
{
options.LoginPath = new PathString("/Account/Index");
options.Cookie.Name = "HeronAuthCookie";
options.Cookie.HttpOnly = true;
});
loServices.AddAuthentication(o =>
{
o.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
o.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.LoginPath = "/Account/Index";
});
loServices.AddDistributedMemoryCache();
loServices.AddMvcCore(options =>
{
options.RespectBrowserAcceptHeader = true;
})
.AddJsonFormatters();
loServices
.AddMvc(options =>
{
options.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
})
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddSessionStateTempDataProvider()
.AddJsonOptions(options => options.SerializerSettings.ContractResolver = new DefaultContractResolver());
loServices.AddKendo();
loServices.Configure<RecaptchaSettings>(this._oConfiguration.GetSection("RecaptchaSettings"));
loServices.AddTransient<IRecaptchaService, RecaptchaService>();
loServices.Configure<IISOptions>(this._oConfiguration);
loServices.Configure<RequestLocalizationOptions>(options =>
{
options.RequestCultureProviders.Clear();
options.DefaultRequestCulture = new Microsoft.AspNetCore.Localization.RequestCulture("en-GB");
options.SupportedCultures = new List<CultureInfo> { new CultureInfo("en-GB") };
});
}
catch (Exception loException)
{
Heron.Library.Classes.Utility.MakeExceptionMessage(loException, "\r\n", "Startup.ConfigureServices");
}
}
public void Configure(IApplicationBuilder loApp, IHostingEnvironment loEnv)
{
try
{
if (!this._bIsStaging)
{
loApp.UseHttpsRedirection();
}
using (var serviceScope = loApp.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
{
var loContext = serviceScope.ServiceProvider.GetService<Heron.Data.DB.HeronContext>();
loContext.Database.EnsureCreated();
loContext.Database.Migrate();
var loContext2 = serviceScope.ServiceProvider.GetService<Heron.Data.DB.Extensions.IdentityExtend.DbContext>();
loContext2.Database.EnsureCreated();
}
if (loEnv.IsDevelopment())
{
loApp.UseDeveloperExceptionPage();
}
else
{
loApp.UseExceptionHandler("/Shared/Error");
loApp.UseHsts();
}
loApp.UseStatusCodePages(async context =>
{
context.HttpContext.Response.ContentType = "text/plain";
await context.HttpContext.Response.WriteAsync("Status code page, status code: " + context.HttpContext.Response.StatusCode);
});
loApp.UseStaticFiles();
loApp.UseSession();
loApp.UseCookiePolicy();
loApp.UseAuthentication();
loApp.UseMvc(routes =>
{
routes.MapRoute(name: "dashboard", template: "{controller=Dashboard}/{action=Index}/{lsData?}");
routes.MapRoute(name: "default", template: "{controller=Account}/{action=Index}/{lsMessage?}");
});
var supportedCultures = new[] { new CultureInfo("en-GB") };
loApp.UseRequestLocalization(new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-GB"),
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
});
}
catch (Exception loException)
{
Heron.Library.Classes.Utility.MakeExceptionMessage(loException, "\r\n", "Startup.Configure");
}
}