Home > Software engineering >  The default Identity UI layout requires a partial view '_LoginPartial' error ASP.NET Core
The default Identity UI layout requires a partial view '_LoginPartial' error ASP.NET Core

Time:03-12

So. I created a fresh new project with Visual Studio Pro 2019 (v16.11.9) using the model ASP.NET Core with Angular. I set the authentication option to Individual User Accounts.
I got a working scaffolded project with Angular 8, ASP.NET Core 3.1 (didn't dig in why those versions, just accepted the fact), Entity Framework and Identity, which is exactly what I want except for the frameworks versions. I want to work with the latest, so Angular 13 and ASP.NET Core 6.0.

So here I go, upgrading my Angular version by version, checking at each step of the way if the app still works. Got to Angular 13, no identified problem, authentication works fine.
I then follow the very complicated (being ironic here) Microsoft tutorial to update your .NET Core version: enter image description here

InvalidOperationException: The default Identity UI layout requires a partial view '_LoginPartial' usually located at '/Pages/_LoginPartial' or at '/Views/Shared/_LoginPartial' to work. Based on your configuration we have looked at it in the following locations: /Areas/Identity/Pages/Account/_LoginPartial.cshtml /Areas/Identity/Pages/_LoginPartial.cshtml /Areas/Identity/Pages/Shared/_LoginPartial.cshtml /Areas/Identity/Views/Shared/_LoginPartial.cshtml /Pages/Shared/_LoginPartial.cshtml /Views/Shared/_LoginPartial.cshtml.

Knowing that, the file it says it cannot find is there.
When I access my app, all seems fine. It's just as I click on Fetch Data, the guarded part of the app, that I get this error.
I decided to upgrade all my dependencies to their v6 counterparts. Same error.
I then dug into this Microsoft article: What's new in ASP.NET Core 6.0 that let me know they migrated the IdentityServer from IdentityServer4 to Duende. I changed the namespace. But it never fixed my app.

We're talking default app from Microsoft that stops working without me mingling with any code, just versioning up the frameworks.
I'm very stuck here and dumbfounded on how this could happen and why nobody ever reported that bug. I can't possibly be the only one wanting to work with latest versions of frameworks but also wanting to take advantage of VS built-in project creator?

Can anyone please help me fix this?

CodePudding user response:

You could get the said error when you move the folder where _LoginPartial is located, the corresponding view will not be found.

If you reference partial view by its name without extension then it will look in the following locations.

/Areas/<Area-Name>/Views/<Controller-Name>
/Areas/<Area-Name>/Views/Shared
/Views/Shared
/Pages/Shared

I found that you could try to use Areas in ASP.NET Core.

Reference: How to move Areas folder to subfolder in DotNet Core with mvc

CodePudding user response:

Sounds like the file has either been moved or not linked correctly.

I would follow this to scaffold the identity again: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-6.0&tabs=netcore-cli

  • Related