Код: Выделить всё
builder.Services.AddScoped();Код: Выделить всё
using Microsoft.AspNetCore.Identity;
namespace Blazorteste.Modelo;
internal sealed class IdentityUserAccessor(UserManager userManager, IdentityRedirectManager redirectManager)
{
public async Task GetRequiredUserAsync(HttpContext context)
{
var user = await userManager.GetUserAsync(context.User);
if (user is null)
{
redirectManager.RedirectToWithStatus("Account/InvalidUser", $"Error: Unable to load user with ID '{userManager.GetUserId(context.User)}'.", context);
}
return user;
}
}
Код: Выделить всё
namespace HoteldosNobresBlazor.Modelo;
public class ApplicationDbContext(DbContextOptions options) : IdentityDbContext(options)
{
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... or-c-sharp