While I was creating a separate project and localizing the problem, I discovered why this error occurs.
Localization stopped working because of this line in Startup-->Configure(): app.UseCookiePolicy();
I commented out this line and immediately everything worked as it should.
I hope this line will not break the work of the project anywhere, but the first tests showed that everything is fine.
Now you can also emulate this problem, if necessary.
Thank you all, the question is closed! :)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization(locOptions.Value);
app.UseHttpsRedirection();
app.UseStaticFiles();
//app.UseCookiePolicy(); // <------------------ Error!
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute("areas", "{area=Customer}/{controller=Home}/{action=Index}/{id?}");
});
}