question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Missing "IdentityHostingStartup.cshtml" when scaffolding Identity

See original GitHub issue

Issue

Identity scaffolding fails with the following error when run by either command line (as below, for any combination of files) or via the IDE context menu (Add -> New Scaffolded Item… -> Identity).

> dotnet aspnet-codegenerator identity -dc MyProject.Data.MyContext --files "Account.Login;Account.Logout"

Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
A file matching the name IdentityHostingStartup.cshtml was not found within any of the folders: C:\Users\Extragorey\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity\Data;C:\Users\Extragorey\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity\Pages;C:\Users\Extragorey\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:07.76

Solution

Manually add IdentityHostingStartup.cshtml to the folder specified (….nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity), copying it from this source. Once added, scaffolding works as expected.

Suggested: Include IdentityHostingStartup.cshtml in the Microsoft.VisualStudio.Web.CodeGenerators.Mvc nuget package distribution.

Environment Info

Libraries: twitter-bootstrap@5.1.3 Target framework: .NET 6.0 IDE: Visual Studio 2022 17.0.1 Operating system: Windows Server 2016 Standard

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:29
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
N1K1TAS95commented, Dec 24, 2021

Issue

Identity scaffolding fails with the following error when run by either command line (as below, for any combination of files) or via the IDE context menu (Add -> New Scaffolded Item… -> Identity).

> dotnet aspnet-codegenerator identity -dc MyProject.Data.MyContext --files "Account.Login;Account.Logout"

Building project ...
Finding the generator 'identity'...
Running the generator 'identity'...
A file matching the name IdentityHostingStartup.cshtml was not found within any of the folders: C:\Users\Extragorey\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity\Data;C:\Users\Extragorey\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity\Pages;C:\Users\Extragorey\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.<BuildCommandLine>b__6_0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.ActionInvoker.Execute(String[] args)
   at Microsoft.VisualStudio.Web.CodeGeneration.CodeGenCommand.Execute(String[] args)
RunTime 00:00:07.76

Solution

Manually add IdentityHostingStartup.cshtml to the folder specified (…nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\6.0.0\Templates\Identity), copying it from this source. Once added, scaffolding works as expected.

Suggested: Include IdentityHostingStartup.cshtml in the Microsoft.VisualStudio.Web.CodeGenerators.Mvc nuget package distribution.

Environment Info

Libraries: twitter-bootstrap@5.1.3 Target framework: .NET 6.0 IDE: Visual Studio 2022 17.0.1 Operating system: Windows Server 2016 Standard

Finally! Worked for me!

2reactions
deepchoudherycommented, Dec 20, 2021

@Extragorey Hey, tracking this issue for the next update. Will update here when it goes out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scaffold Identity in ASP.NET Core projects
From the left pane of the Add New Scaffolded Item dialog, select Identity. Select Identity in the center pane. Select the Add button....
Read more >
Layout for Identity/Account/Manage pages broken after ...
The side menu is missing. The app is no longer finding Areas/Identity/Pages/Account/Manage/_Layout.cshtml , and I don't understand why.
Read more >
Implement Identity On Existing ASP.NET Project
Tutorial step-by-step to add Identity to an existing ASP.NET project. Scaffold the required pages and customize them with your code.
Read more >
Blazor Server Project #12: Installing ASP.NET Core Identity
An initial guide to security: installing Identity and adding its database to ... Missing "IdentityHostingStartup.cshtml" when scaffolding Identity · Issue ...
Read more >
Customising the ASP.NET Core default UI without editing ...
In this post I show how you can replace the Razor views for the ASP.NET Core Identity default UI, without having to replace...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found