添加身份支架

Add Identity Scaffold

我在尝试添加身份支架时遇到问题。

这是添加身份支架的照片:

身份支架的所有页面都加载到帐户中。

如果我删除身份支架的页面,Web 服务将正常工作。

这是 404 Chrome 和 Visual Studio 中的照片:

这是Program.cs

的代码
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(
builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddDefaultIdentity<IdentityUser>(options => 
     options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();
builder.Services.AddScoped<IUnitOfWork, UnitOfWork>();
builder.Services.AddRazorPages().AddRazorRuntimeCompilation();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();

app.MapControllerRoute(
   name: "default",
   pattern: "{area=Customer}/{controller=Home}/{action=Index}/{id?}");
app.Run();

您应该在 Areas/Customer/Controllers 文件夹中有一个 HomeController。并且控制器应该有一个动作索引,你应该在 Areas/Customer/Views 文件夹中有一个名为索引的视图。你正在映射到那个,但从上面我没有看到你有这个:Areas/Customer/Controllers/HomeController。 检查区域文件夹结构 - https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/areas?view=aspnetcore-6.0

我添加到 HomeController,它开始工作了。

[Area("Customer")]

Area 很奇怪,因为它以前没有属性。