skip to Main Content

I have a problem when I trying to add Identity Scaffold.

Here are photo of adding Identity Scaffold:

All pages of Identity Scaffold are loaded in Account.

If I remove pages of Identity Scaffold, the web service will be working.enter image description here

Here are the photos of 404 Chrome and in Visual Studio:enter image description here

enter image description here
enter image description here
enter image description here

Here are is code of 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();

2

Answers


  1. Chosen as BEST ANSWER

    I added to HomeController and it is started to work.

    [Area("Customer")]
    

    It is strange with Area, because it was working before without attribute.


  2. You should have a HomeController in the Areas/Customer/Controllers folder. And the controller should have an action Index and you should have a view named Index in the Areas/Customer/Views folder. You are mapping to that, but from the above I don’t see that you have this: Areas/Customer/Controllers/HomeController.
    Check this for Areas folder structure – https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/areas?view=aspnetcore-6.0

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search