GetRequiredUserAsync(HttpContext context)
9 | {
10 | var user = await userManager.GetUserAsync(context.User);
11 |
12 | if (user is null)
13 | {
14 | redirectManager.RedirectToWithStatus("Account/InvalidUser", $"Error: Unable to load user with ID '{userManager.GetUserId(context.User)}'.", context);
15 | }
16 |
17 | return user;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/ForgotPasswordConfirmation.razor:
--------------------------------------------------------------------------------
1 | @page "/Account/ForgotPasswordConfirmation"
2 |
3 | Forgot password confirmation
4 |
5 | Forgot password confirmation
6 |
7 | Please check your email to reset your password.
8 |
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/InvalidPasswordReset.razor:
--------------------------------------------------------------------------------
1 | @page "/Account/InvalidPasswordReset"
2 |
3 | Invalid password reset
4 |
5 | Invalid password reset
6 |
7 | The password reset link is invalid.
8 |
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/InvalidUser.razor:
--------------------------------------------------------------------------------
1 | @page "/Account/InvalidUser"
2 |
3 | Invalid user
4 |
5 | Invalid user
6 |
7 |
8 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/Lockout.razor:
--------------------------------------------------------------------------------
1 | @page "/Account/Lockout"
2 |
3 | Locked out
4 |
5 |
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/Manage/_Imports.razor:
--------------------------------------------------------------------------------
1 | @layout ManageLayout
2 | @attribute [Microsoft.AspNetCore.Authorization.Authorize]
3 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/ResetPasswordConfirmation.razor:
--------------------------------------------------------------------------------
1 | @page "/Account/ResetPasswordConfirmation"
2 | Reset password confirmation
3 |
4 | Reset password confirmation
5 |
6 | Your password has been reset. Please click here to log in.
7 |
8 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Pages/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using VolumeMount.BlazorWeb.Components.Account.Shared
2 | @layout AccountLayout
3 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Shared/AccountLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 | @layout VolumeMount.BlazorWeb.Components.Layout.MainLayout
3 | @inject NavigationManager NavigationManager
4 |
5 | @if (HttpContext is null)
6 | {
7 | Loading...
8 | }
9 | else
10 | {
11 | @Body
12 | }
13 |
14 | @code {
15 | [CascadingParameter]
16 | private HttpContext? HttpContext { get; set; }
17 |
18 | protected override void OnParametersSet()
19 | {
20 | if (HttpContext is null)
21 | {
22 | // If this code runs, we're currently rendering in interactive mode, so there is no HttpContext.
23 | // The identity pages need to set cookies, so they require an HttpContext. To achieve this we
24 | // must transition back from interactive mode to a server-rendered page.
25 | NavigationManager.Refresh(forceReload: true);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Shared/ManageLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 | @layout AccountLayout
3 |
4 | Manage your account
5 |
6 |
7 |
Change your account settings
8 |
9 |
10 |
11 |
12 |
13 |
14 | @Body
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Shared/RedirectToLogin.razor:
--------------------------------------------------------------------------------
1 | @inject NavigationManager NavigationManager
2 |
3 | @code {
4 | protected override void OnInitialized()
5 | {
6 | NavigationManager.NavigateTo($"Account/Login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}", forceLoad: true);
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Shared/ShowRecoveryCodes.razor:
--------------------------------------------------------------------------------
1 |
2 | Recovery codes
3 |
4 |
5 | Put these codes in a safe place.
6 |
7 |
8 | If you lose your device and don't have the recovery codes you will lose access to your account.
9 |
10 |
11 |
12 |
13 | @foreach (var recoveryCode in RecoveryCodes)
14 | {
15 |
16 | @recoveryCode
17 |
18 | }
19 |
20 |
21 |
22 | @code {
23 | [Parameter]
24 | public string[] RecoveryCodes { get; set; } = [];
25 |
26 | [Parameter]
27 | public string? StatusMessage { get; set; }
28 | }
29 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Account/Shared/StatusMessage.razor:
--------------------------------------------------------------------------------
1 | @if (!string.IsNullOrEmpty(DisplayMessage))
2 | {
3 | var statusMessageClass = DisplayMessage.StartsWith("Error") ? "danger" : "success";
4 |
5 | @DisplayMessage
6 |
7 | }
8 |
9 | @code {
10 | private string? messageFromCookie;
11 |
12 | [Parameter]
13 | public string? Message { get; set; }
14 |
15 | [CascadingParameter]
16 | private HttpContext HttpContext { get; set; } = default!;
17 |
18 | private string? DisplayMessage => Message ?? messageFromCookie;
19 |
20 | protected override void OnInitialized()
21 | {
22 | messageFromCookie = HttpContext.Request.Cookies[IdentityRedirectManager.StatusCookieName];
23 |
24 | if (messageFromCookie is not null)
25 | {
26 | HttpContext.Response.Cookies.Delete(IdentityRedirectManager.StatusCookieName);
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/App.razor:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Layout/MainLayout.razor:
--------------------------------------------------------------------------------
1 | @inherits LayoutComponentBase
2 |
3 |
4 |
7 |
8 |
9 |
12 |
13 |
14 | @Body
15 |
16 |
17 |
18 |
19 |
20 | An unhandled error has occurred.
21 |
Reload
22 |
🗙
23 |
24 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Pages/Auth.razor:
--------------------------------------------------------------------------------
1 | @page "/auth"
2 |
3 | @using Microsoft.AspNetCore.Authorization
4 |
5 | @attribute [Authorize]
6 |
7 | Auth
8 |
9 | You are authenticated
10 |
11 |
12 | Hello @context.User.Identity?.Name!
13 |
14 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Pages/Counter.razor:
--------------------------------------------------------------------------------
1 | @page "/counter"
2 | @rendermode InteractiveServer
3 |
4 | Counter
5 |
6 | Counter
7 |
8 | Current count: @currentCount
9 |
10 |
11 |
12 | @code {
13 | private int currentCount = 0;
14 |
15 | private void IncrementCount()
16 | {
17 | currentCount++;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Pages/Home.razor:
--------------------------------------------------------------------------------
1 | @page "/"
2 |
3 | Home
4 |
5 | Hello, world!
6 |
7 | Welcome to your new app.
8 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/Routes.razor:
--------------------------------------------------------------------------------
1 | @using VolumeMount.BlazorWeb.Components.Account.Shared
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Components/_Imports.razor:
--------------------------------------------------------------------------------
1 | @using System.Net.Http
2 | @using System.Net.Http.Json
3 | @using Microsoft.AspNetCore.Components.Authorization
4 | @using Microsoft.AspNetCore.Components.Forms
5 | @using Microsoft.AspNetCore.Components.Routing
6 | @using Microsoft.AspNetCore.Components.Web
7 | @using static Microsoft.AspNetCore.Components.Web.RenderMode
8 | @using Microsoft.AspNetCore.Components.Web.Virtualization
9 | @using Microsoft.JSInterop
10 | @using VolumeMount.BlazorWeb
11 | @using VolumeMount.BlazorWeb.Components
12 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Data/ApplicationDbContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
2 | using Microsoft.EntityFrameworkCore;
3 |
4 | namespace VolumeMount.BlazorWeb.Data;
5 |
6 | public class ApplicationDbContext(DbContextOptions options) : IdentityDbContext(options)
7 | {
8 | }
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Data/ApplicationUser.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Identity;
2 |
3 | namespace VolumeMount.BlazorWeb.Data;
4 |
5 | // Add profile data for application users by adding properties to the ApplicationUser class
6 | public class ApplicationUser : IdentityUser
7 | {
8 | }
9 |
10 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Data/PostgresDbContext.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.EntityFrameworkCore;
2 |
3 | namespace VolumeMount.BlazorWeb.Data;
4 |
5 | public class PostgresDbContext(DbContextOptions options) : DbContext(options)
6 | {
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/launchsettings.json",
3 | "iisSettings": {
4 | "windowsAuthentication": false,
5 | "anonymousAuthentication": true,
6 | "iisExpress": {
7 | "applicationUrl": "http://localhost:4597",
8 | "sslPort": 44356
9 | }
10 | },
11 | "profiles": {
12 | "http": {
13 | "commandName": "Project",
14 | "dotnetRunMessages": true,
15 | "launchBrowser": true,
16 | "applicationUrl": "http://localhost:5034",
17 | "environmentVariables": {
18 | "ASPNETCORE_ENVIRONMENT": "Development"
19 | }
20 | },
21 | "https": {
22 | "commandName": "Project",
23 | "dotnetRunMessages": true,
24 | "launchBrowser": true,
25 | "applicationUrl": "https://localhost:7235;http://localhost:5034",
26 | "environmentVariables": {
27 | "ASPNETCORE_ENVIRONMENT": "Development"
28 | }
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Properties/serviceDependencies.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "mssql1": {
4 | "type": "mssql",
5 | "connectionId": "ConnectionStrings:DefaultConnection"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/Properties/serviceDependencies.local.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "mssql1": {
4 | "type": "mssql.local",
5 | "connectionId": "ConnectionStrings:DefaultConnection"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft.AspNetCore": "Information"
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "ConnectionStrings": {
3 | "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-VolumeMount.BlazorWeb-9d3e705c-96bc-40ba-a6e8-3862004ea1e2;Trusted_Connection=True;MultipleActiveResultSets=true"
4 | },
5 | "Logging": {
6 | "LogLevel": {
7 | "Default": "Information",
8 | "Microsoft.AspNetCore": "Information"
9 | }
10 | },
11 | "AllowedHosts": "*"
12 | }
13 |
--------------------------------------------------------------------------------
/samples/VolumeMount/VolumeMount.BlazorWeb/wwwroot/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/aspire-samples/bf62e3a8813fd916bcad455a6be4014a6b6f8984/samples/VolumeMount/VolumeMount.BlazorWeb/wwwroot/favicon.png
--------------------------------------------------------------------------------
/samples/VolumeMount/images/volume-mount-frontend-account-registered.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/aspire-samples/bf62e3a8813fd916bcad455a6be4014a6b6f8984/samples/VolumeMount/images/volume-mount-frontend-account-registered.png
--------------------------------------------------------------------------------
/samples/VolumeMount/images/volume-mount-frontend-dbcontext-error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/aspire-samples/bf62e3a8813fd916bcad455a6be4014a6b6f8984/samples/VolumeMount/images/volume-mount-frontend-dbcontext-error.png
--------------------------------------------------------------------------------
/samples/VolumeMount/images/volume-mount-frontend-email-confirmed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/aspire-samples/bf62e3a8813fd916bcad455a6be4014a6b6f8984/samples/VolumeMount/images/volume-mount-frontend-email-confirmed.png
--------------------------------------------------------------------------------
/samples/VolumeMount/images/volume-mount-frontend-login.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/aspire-samples/bf62e3a8813fd916bcad455a6be4014a6b6f8984/samples/VolumeMount/images/volume-mount-frontend-login.png
--------------------------------------------------------------------------------
/samples/VolumeMount/images/volume-mount-frontend-register.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/aspire-samples/bf62e3a8813fd916bcad455a6be4014a6b6f8984/samples/VolumeMount/images/volume-mount-frontend-register.png
--------------------------------------------------------------------------------
/tests/SamplesIntegrationTests/Infrastructure/ResourceExtensions.cs:
--------------------------------------------------------------------------------
1 | // Licensed to the .NET Foundation under one or more agreements.
2 | // The .NET Foundation licenses this file to you under the MIT license.
3 |
4 | namespace SamplesIntegrationTests.Infrastructure;
5 |
6 | internal static class ResourceExtensions
7 | {
8 | ///
9 | /// Gets the name of the based on the project file path.
10 | ///
11 | public static string GetName(this ProjectResource project)
12 | {
13 | var metadata = project.GetProjectMetadata();
14 | return Path.GetFileNameWithoutExtension(metadata.ProjectPath);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tests/SamplesIntegrationTests/xunit.runner.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
3 | "diagnosticMessages": true,
4 | "longRunningTestSeconds": 120,
5 | "stopOnFail": true,
6 | "showLiveOutput": true
7 | }
--------------------------------------------------------------------------------