'ASP.NET Core Identity User logged out randomly after a few minutes. But not on Localhost
Whenever I am on localhost, everything works perfectly. Once I publish to the webserver, a user will only be able to stay logged in after a few minutes sometimes even less with little to no consistency.
Here is my Startup.cs.ConfigureServices:
public void ConfigureServices(IServiceCollection services)
{
// MVC Shit
services.AddControllers(options => options.EnableEndpointRouting = false);
// DBContext shit
services.AddDbContextPool<ventsus7_InventoryContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddScoped<IIMS, IMSSQL>();
services.AddDbContext<EcommerceWebsiteContext>(options =>
options.UseSqlServer(
Configuration.GetConnectionString("DefaultConnection")));
// Identity shit
services.AddIdentity<EcommerceWebsiteUser, IdentityRole>(config =>
{
config.SignIn.RequireConfirmedEmail = true;
})
.AddDefaultUI()
.AddEntityFrameworkStores<EcommerceWebsiteContext>().AddDefaultTokenProviders();
services.AddAuthentication();
services.AddAuthorization();
// Cache
services.AddMemoryCache();
services.AddSession(options =>
{
//options.IdleTimeout = TimeSpan.FromDays(10);
options.Cookie.IsEssential = true;
});
// Payments Stuff
StripeConfiguration.ApiKey = Configuration.GetSection("Stripe")["SecretKey"];
}
This is the Startup.cs.Configure:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
//app.UseHttpsRedirection();
app.UseStaticFiles();
//app.UseRouting();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseAuthorization();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
});
}
I really don't even know where to start looking. Any help would be great.
Update:
I was asked to find the bearer token, however, I don't see one. Below is a screenshot of what I found. (Please keep in mind, I don't know what any of these are or how this all works)

Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
