DotNetDublin
DotNetDublin

Reputation: 798

Error when scaffolding identity in server side Blazor project

I'm working on a server-side Blazor application which was created with the "Individual User Accounts" option selected for Authentication.

I now want to customise the login page however when I select to add the Identity pages via scaffolding I receive the below error and I'm not sure where to start in terms of troubleshooting.

Failed to compile the project in memory

.OnInitializedAynsc() no suitable method found to overrirde

The above error is listed for each page within my project.

enter image description here

Upvotes: 5

Views: 2060

Answers (2)

jamie yello
jamie yello

Reputation: 87

enter image description here

I fixed a similar issue in my Blazor Server project by ensuring that no code defined in a .cs file ever called any public static methods/classes/enums defined in any .razor file. For whatever reason, that just fixed scaffolding for me. For me, all these errors were detailed in the error box.

The VS compiler will tolerate these calls but the ASP.NET code generator will not. At least not yet.

Upvotes: 1

Umair
Umair

Reputation: 5501

I think your EditAdministrator class is not inheriting from ComponentBase and your EditAdministrator.razor should inherit from EditAdministrator.razor.cs

So an example code will be as below:

EditAdministrator.razor page class will have this on top:

@inherits EditAdministratorBase

And your EditAdministrator.razor.cs class:

public class EditAdministratorBase : ComponentBase

Upvotes: 11

Related Questions