2
I did a program in ASP.NET Core
MVC, which has the class Startup
as:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//...
services.AddIdentity<AppUser, IdentityRole>()
.AddEntityFrameworkStores<idDataContext>()
.AddDefaultTokenProviders();
services.ConfigureApplicationCookie(opts =>
{
opts.LoginPath = "/Account/Login";
opts.AccessDeniedPath = "/Account/AccessDenied";
opts.ExpireTimeSpan = TimeSpan.FromHours(4);
});
//...
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddMemoryCache();
services.AddSession();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, AppFeatures features)
{
//...
app.UseAuthentication();
//...
app.UseCookiePolicy();
app.Use(async (context, next) =>
{
if (context.Request.Path.Value.Contains("error"))
throw new Exception("Erro: caminho contém 'error'!");
await next();
});
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseFileServer();
}
}
I am indicating that the login cookie and session cookie (with data from my app) last 4h? This is missing somewhere else?
It is that apparently the sessions do not last 4h in the client. There is some error?
Thank you.