# Refresh tokens with ASP.NET Core MVC

**URL:** <https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714>\
**Category:** Get Help\
**Tags:** refresh-tokens, auth0\
**Created:** [August 9, 2020, 8:50pm UTC](https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714 "2020-08-09T20:50:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarrichvdv](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jarrichvdv/32/14721_2.png) [@jarrichvdv](https://community.auth0.com/u/jarrichvdv)\
**Post date:** [August 9, 2020, 8:50pm UTC](https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714/1 "2020-08-09T20:50:56Z")

</div>

Hi all,

There is a lot of information regarding the use of Refresh tokens with several different back-ends, including [ASP.NET](http://ASP.NET) Core (which we’re using). However, I am currently working on an MVC app, and I want to make sure that users who log in, actually stay logged in forever (across browser sessions), but I obviously do want to support the revocation of their token under certain conditions (such as a password change).

Since I’m using basic MVC, no front-end app framework, nearly every user interaction results in a page navigation.

I am struggling to figure out how & when to handle with keeping the access token up to date in this type of application where there is almost no application state on the client side.

Willing to provide more context if needed, since I’m left scratching my head but I really want to use Auth0 for our authentication.

Regards,  
Jarrich

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 17, 2020, 9:28pm UTC](https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714/2 "2020-08-17T21:28:30Z")

</div>

Hi @jarrichvdv,

Welcome to the Community!

> [@jarrichvdv](#):
>
> I am struggling to figure out how & when to handle with keeping the access token up to date in this type of application where there is almost no application state on the client side.

You should request a new access token when the existing access token expires. A refresh token allows the user to stay “logged in” perpetually (unless revoked), and regularly requesting fresh access tokens means the user’s info/permissions/roles are up to date.

---

<div class="post-metadata">

**Author:** ![jarrichvdv](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jarrichvdv/32/14721_2.png) [@jarrichvdv](https://community.auth0.com/u/jarrichvdv)\
**Post date:** [August 17, 2020, 9:38pm UTC](https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714/3 "2020-08-17T21:38:25Z")

</div>

Hi Dan,

Thanks for taking the time to reply.

Perhaps my original question was not phrased accurately, or i am missing an important concept here.

How can i request a new fresh access token before the current one expires in a traditional MVC app? Since there is no client framework to speak off… I really cant get my head around it. Every user interaction is basically a page navigation, so what if a page navigation suddenly occurs with an expired token?

Thank you,

Jarrich

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [August 19, 2020, 3:37pm UTC](https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714/4 "2020-08-19T15:37:21Z")

</div>

@jarrichvdv,

You could check if a token is expired with the `exp` claim before sending it, or build your error handling to request a new one if an expired token error is returned.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [September 2, 2020, 7:37pm UTC](https://community.auth0.com/t/refresh-tokens-with-asp-net-core-mvc/47714/5 "2020-09-02T19:37:27Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
