|
1 | 1 | --- |
2 | | -title: Update ASP.NET or ASP.NET Core App Session to Last Longer Than Entra ID Tokens |
3 | | -description: Describes a problem in which Microsoft Entra ID is sending the token to an incorrect reply URL endpoint or localhost. |
4 | | -ms.date: 08/26/2022 |
5 | | -ms.reviewer: bernawy |
| 2 | +title: Configure ASP.NET or ASP.NET Core App Session to Last Longer Than Entra ID Tokens |
| 3 | +description: Describes how to configure ASP.NET or ASP.NET Core App session to last longer than Microsoft Entra ID token. |
| 4 | +ms.date: 05/31/2025 |
| 5 | +ms.reviewer: willfid |
6 | 6 | ms.service: entra-id |
7 | 7 | ms.custom: sap:Developing or Registering apps with Microsoft identity platform |
8 | 8 | --- |
9 | | -# Update ASP.NET or ASP.NET Core App Session to Last Longer Than Azure AD Tokens |
| 9 | +# Customize Middleware authentication ticket to extend user sign-in time |
10 | 10 |
|
11 | | -Microsoft Entra ID tokens (ID tokens, access tokens, and SAML tokens) by default last one hour. Asp.Net and Asp.Net Core Middleware set their authentication ticket to the expiration of these tokens by default. If you do not want your web application to redirect users to Microsoft Entra ID to sign in again, you can customize the Middleware authentication ticket. |
| 11 | +Microsoft Entra ID tokens (ID tokens, access tokens, and SAML tokens) by default expire after one hour. ASP.NET and ASP.NET Core Middleware set their authentication ticket to the expiration of these tokens by default. If you don't want your web application to redirect users to Microsoft Entra ID to sign in again, you can customize the Middleware authentication ticket. |
12 | 12 |
|
13 | 13 | This customization can also help resolve AJAX issues (such as CORS errors to `login.microsoftonline.com`) where your app is both a Web App and Web API. |
14 | 14 |
|
@@ -40,9 +40,9 @@ app.UseOpenIdConnectAuthentication( |
40 | 40 |
|
41 | 41 | ``` |
42 | 42 |
|
43 | | -## For Asp.Net Core |
| 43 | +## For ASP.NET Core |
44 | 44 |
|
45 | | -In ASP.NET Core, you need to add the `OnTokenValidated` event to update the ticket properties. This sets the ticket expiration time before the application redirects to Microsoft Entra ID for re-authentication. |
| 45 | +In ASP.NET Core, you need to add the `OnTokenValidated` event to update the ticket properties. This sets the ticket expiration time before the application redirects to Microsoft Entra ID for reauthentication. |
46 | 46 |
|
47 | 47 | ``` |
48 | 48 | services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme, options => |
@@ -184,7 +184,7 @@ services.Configure<OpenIdConnectOptions>(options => |
184 | 184 | }); |
185 | 185 | ``` |
186 | 186 |
|
187 | | -If you're integrating a Asp.Net Core WS-Fed application, then it might look something like the following: |
| 187 | +If you're integrating a ASP.NET Core WS-Fed application, then it might look something like the following: |
188 | 188 |
|
189 | 189 | ```csharp |
190 | 190 | public void ConfigureServices(IServiceCollection services) |
|
0 commit comments