# Session Expire

**URL:** <https://forum.radzen.com/t/session-expire/5286>\
**Category:** Blazor Server\
**Created:** [October 14, 2020, 9:19am UTC](https://forum.radzen.com/t/session-expire/5286 "2020-10-14T09:19:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnmu](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@johnmu](https://forum.radzen.com/u/johnmu)\
**Post date:** [October 14, 2020, 9:19am UTC](https://forum.radzen.com/t/session-expire/5286/1 "2020-10-14T09:19:47Z")

</div>

Folk,

Blazor server side

I need the system to log users out after say 30mins of no activity. Does anyone know how i can make this happen?

Thanks

John

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 14, 2020, 9:40am UTC](https://forum.radzen.com/t/session-expire/5286/2 "2020-10-14T09:40:48Z")

</div>

Hi @johnmu,

You can try [this](https://stackoverflow.com/a/47146191/10141) StackOverflow answer. You will need to create a partial class for your Startup as described in the [Custom Startup section](https://www.radzen.com/documentation/blazor/customizing-generated-application/#custom-startup) of our article.

---

<div class="post-metadata">

**Author:** ![johnmu](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@johnmu](https://forum.radzen.com/u/johnmu)\
**Post date:** [October 15, 2020, 12:38pm UTC](https://forum.radzen.com/t/session-expire/5286/3 "2020-10-15T12:38:23Z")

</div>

Atanas,

I have tried this

```
public partial class Startup
{
    partial void OnConfigureServices(IServiceCollection services)
    {
        services.ConfigureApplicationCookie(options =>
        {
            options.ExpireTimeSpan = TimeSpan.FromMinutes(1);
        });
    }

}

```

}

the OnConfigure method won't compile, probably because i don't know what directive to add.

Any thoughts?

thanks John

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 15, 2020, 2:29pm UTC](https://forum.radzen.com/t/session-expire/5286/4 "2020-10-15T14:29:59Z")

</div>

What are the compilation errors? Usually some namespace is not imported.

---

<div class="post-metadata">

**Author:** ![johnmu](https://forum.radzen.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@johnmu](https://forum.radzen.com/u/johnmu)\
**Post date:** [October 16, 2020, 11:17am UTC](https://forum.radzen.com/t/session-expire/5286/5 "2020-10-16T11:17:11Z")

</div>

this is what happens when i copy the OnConfigure method intot the class

 ![image](https://forum.radzen.com/uploads/default/original/2X/0/0c7f75b4466243c04b690b461d8cbab2735b6b29.png)

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 16, 2020, 1:02pm UTC](https://forum.radzen.com/t/session-expire/5286/6 "2020-10-16T13:02:15Z")

</div>

Indeed the actual signature of the method should be

```auto
partial void OnConfigure(IApplicationBuilder app, IWebHostEnvironment env)
{
}

```

I will update the documentation.

---

<div class="post-metadata">

**Author:** ![Hoang](https://forum.radzen.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@Hoang](https://forum.radzen.com/u/Hoang)\
**Post date:** [October 21, 2026, 2:43am UTC](https://forum.radzen.com/t/session-expire/5286/7 "2026-10-21T02:43:49Z")

</div>

Hi,  
I’m trying to do the same thing for .Net8 and .Net10 but got error on OnConfigureServices  
Program.Custom.cs(8,22): error CS0759: No defining declaration found for implementing declaration of partial method 'Program.OnConfigureServices(IServiceCollection)'  
Please help. Thanks.

 ![image](https://forum.radzen.com/uploads/default/original/3X/6/5/65dfeeaab3dccdfcc8af321844d814045b1641ca.png)

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 21, 2026, 4:11am UTC](https://forum.radzen.com/t/session-expire/5286/8 "2026-10-21T04:11:09Z")

</div>

Hi @Hoang,

You need to do that in Program.cs itself:

```auto
builder.Services.ConfigureApplicationCookie(options =>
{
    options.ExpireTimeSpan = new TimeSpan(8, 0, 0);
});

```

---

<div class="post-metadata">

**Author:** ![Hoang](https://forum.radzen.com/letter_avatar_proxy/v4/letter/h/9de0a6/32.png) [@Hoang](https://forum.radzen.com/u/Hoang)\
**Post date:** [October 23, 2026, 2:11am UTC](https://forum.radzen.com/t/session-expire/5286/9 "2026-10-23T02:11:41Z")

</div>

Thanks @korchev for your quick reply.
