Identity MVC scaffolding does utilize scaffolded assets
- Dominant language
- C#
- Stars
- 818
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 10
Description
## 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`:
```csharp
builder.Services.AddRazorPages();
// ...
var app = builder.Build();
// ...
app.MapStaticAssets();
app.MapRazorPages()
.WithStaticAssets();
```
_💭 Thought: Maybe these changes should be included by the scaffolder as well? 💭_
6. Make a trivial edit to one of the scaffolded assets (e.g., add a comment in `bootstrap.css`)
7. Run the app, and navigate to the `/identity/account/login` page
8. 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`.
Contributor guide
Assessment
This issue has not been assessed yet.