Open Closed

In our Blazor server application, about the termination of the user's session if he does not perform any operations for a certain period of time #5740


User avatar
0
SevdeDuran created

In our Blazor server application, we want the user's session to end if he or she does not perform any operations for a certain period of time. For this, I wrote the following codes in the program.cs file, but it did not work. While the user's password can be changed within a certain period of time in the interface, I could not find a setting related to this. How do we do it?

Here is my codes:

builder.Services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; })
.AddCookie(options =>
 { 
      options.ExpireTimeSpan = TimeSpan.FromMinutes(10); 
      options.SlidingExpiration = true; 
});
Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

35 Answer(s)
  • User Avatar
    0
    SevdeDuran created

    Hi,
    When I click on the other menu after 3 minutes, the logs;

    2023-09-12 17:38:06.446 +03:00 [DBG] Added 0 entity changes to the current audit log 2023-09-12 17:38:06.455 +03:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Content.RemoteStreamContent'. 2023-09-12 17:38:06.459 +03:00 [INF] Executed action Volo.Abp.Account.AccountController.GetProfilePictureFileAsync (Volo.Abp.Account.Pro.Public.HttpApi) in 76.3419ms 2023-09-12 17:38:06.459 +03:00 [INF] Executed endpoint 'Volo.Abp.Account.AccountController.GetProfilePictureFileAsync (Volo.Abp.Account.Pro.Public.HttpApi)' 2023-09-12 17:38:06.462 +03:00 [INF] Request finished HTTP/2 GET https://localhost:44329/api/account/profile-picture-file/3a0b59c5-6aac-0e69-ed96-002240642456 - - - 200 1370 image/jpeg 118.7899ms 2023-09-12 17:38:25.054 +03:00 [DBG] Batch acquisition of 0 triggers 2023-09-12 17:38:52.866 +03:00 [DBG] Batch acquisition of 0 triggers 2023-09-12 17:39:16.410 +03:00 [DBG] Batch acquisition of 0 triggers 2023-09-12 17:39:43.014 +03:00 [DBG] Batch acquisition of 0 triggers 2023-09-12 17:40:07.666 +03:00 [DBG] Batch acquisition of 0 triggers

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Can you share your project?

    or you can test the code in a new project and share it.

    liming.ma@volosoft.com

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Where is the ConfigureApplicationCookie code?

    Can you share a template project with ConfigureApplicationCookie code?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    SevdeDuran created

    Hi,

    I'm sharing now.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Just a moment, I'll confirm it again.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    context.Services.ConfigureApplicationCookie(options =>
    {
        options.ExpireTimeSpan = TimeSpan.FromSeconds(10);
        options.SlidingExpiration = true;
        options.Events.OnSigningIn = cookie =>
        {
            cookie.Properties.IsPersistent = true;
            return Task.CompletedTask;
        };
    });
    
    Configure<AbpEndpointRouterOptions>(options =>
    {
        options.EndpointConfigureActions.RemoveAll(x => x.Target.GetType().FullName.Contains("AbpAspNetCoreComponentsServerModule"));
        options.EndpointConfigureActions.Add(endpointContext =>
        {
            endpointContext.Endpoints.MapBlazorHub(httpConnectionDispatcherOptions => httpConnectionDispatcherOptions.CloseOnAuthenticationExpiration = true);
            endpointContext.Endpoints.MapFallbackToPage("/_Host");
        });
    });
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    SevdeDuran created

    Hi,

    Thank you so much you are amazing :)

    When I click on another menu, it logs out after 10 seconds or when I don't click on anything. Could you share the sample project I sent you with the latest edit you made?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    These are the changes: https://support.abp.io/QA/Questions/5740#answer-3a0da383-face-7d11-aa37-6152b014966e

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    SevdeDuran created

    Hi,

    Thanks. :)

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    : )

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.