Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identity MVC scaffolding does utilize scaffolded assets #2973

Open
MackinnonBuck opened this issue Sep 18, 2024 · 0 comments
Open

Identity MVC scaffolding does utilize scaffolded assets #2973

MackinnonBuck opened this issue Sep 18, 2024 · 0 comments

Comments

@MackinnonBuck
Copy link
Member

Summary

When scaffolding Identity UI into a project without an existing _Layout.cshtml, the scaffolder (dotnet aspnet-codegenerator identity) doesn't generate links pointing to the scaffolded assets in the project. Instead, it points to the assets provided by the Microsoft.AspNetCore.Identity.UI package.

Steps to reproduce

  1. Create a new ASP.NET Core Web API App (dotnet new webapi)
  2. Add the necessary packages to the project:
    dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
    dotnet add package Microsoft.EntityFrameworkCore.Design
    dotnet add package Microsoft.AspNetCore.Identity.EntityFrameworkCore
    dotnet add package Microsoft.AspNetCore.Identity.UI
    dotnet add package Microsoft.EntityFrameworkCore.SqlServer
    dotnet add package Microsoft.EntityFrameworkCore.Tools
    
  3. Run the scaffolder:
    dotnet aspnet-codegenerator identity
    
    NOTE: The --useDefaultUI flag is intentionally excluded here
  4. Add the following lines to Program.cs:
    builder.Services.AddRazorPages();
    // ...
    var app = builder.Build();
    // ...
    app.MapStaticAssets();
    app.MapRazorPages()
        .WithStaticAssets();
    💭 Thought: Maybe these changes should be included by the scaffolder as well? 💭
  5. Make a trivial edit to one of the scaffolded assets (e.g., add a comment in bootstrap.css)
  6. Run the app, and navigate to the /identity/account/login page
  7. Look at the sources tab, and notice that the loaded assets don't include the edit made in step 5.

Expected behavior

When not specifying the --useDefaultUI option, the links in _Layout.cshtml should point to scaffolded assets, not assets in the Microsoft.AspNetCore.Identity.UI package.

Actual behavior

Each resource link in _Layout.cshtml has an ~/Identity prefix, which causes the assets to be loaded from Microsoft.AspNetCore.Identity.UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant