I am trying to Scaffold Identity UI containing Login.cshtml
and Register.cshtml
for my ASP.NET Core application.
The code in my Program.cs
file is:
using ObjectCrudApp.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using ObjectCrudApp.Areas.Identity.Data;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container
builder.Services.AddDbContext<AppDbContext>(options =>
options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<ObjectCrudAppIdentityDbContext>();
// Configure Identity services
builder.Services.AddIdentity<IdentityUser, IdentityRole>(options =>
options.SignIn.RequireConfirmedAccount = false) // Customize as per your needs
.AddEntityFrameworkStores<AppDbContext>() // Use the same DbContext for both App and Identity
.AddDefaultTokenProviders();
// Configure Application Cookie for Access Denied
builder.Services.ConfigureApplicationCookie(options =>
{
options.AccessDeniedPath = "/Identity/Account/AccessDenied"; // Path to redirect when access is denied
});
// Add MVC services to the container
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts(); // HTTP Strict Transport Security
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthentication(); // Make sure authentication comes before authorization
app.UseAuthorization();
// Map the controller routes
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
I ran the command:
dotnet aspnet-codegenerator identity --useDefaultUI --fo
but it creates only _ValidationScriptsPartial.cshtml
and _ViewStart.cshtml
under the Areas/Pages
, but I want all files:
Login.cshtml
, Register.cshtml
, AccessDenied.cshtml
, ForgotPassword.cshtml
, ResetPassword.cshtml
Here is the screenshot of my project directory:

I am trying to Scaffold Identity UI containing Login and Register for my ASP.NET Core application. I want my command to generate Login.cshtml
and Register.cshtml
and after I run scaffolding command I dont get those pages.