question

davidbuckley-4911 avatar image
0 Votes"
davidbuckley-4911 asked Bruce-SqlWork answered

Scaffolding failing for identity in blazor

When I try to add identity thru the cli cause the tooling is broken form the gui I get this error. I am using Blazor / Client Server. I persume I would scaffold my identity pages to the client.

Inference.targets(188,5): error NETSDK1032: The RuntimeIdentifier platform 'browser-wasm' and the PlatformTarget 'x64'
must be compatible.

I am running the scaffolding via this method

dotnet aspnet-codegenerator identity

As when I run it from the GuI it throws an error.

dotnet-csharpdotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
1 Vote"
Bruce-SqlWork answered AgaveJoe commented

Blazor Client (WASM) projects do not support database scaffolding as the browser does not have database support.

A blazor client would typically use oauth, and the login server project would be the one to support identity database scaffolding. That is the clamor client would call a login server and get a JWT token, that it passed as a bearer token when calling a webapi.

Note. If you used cookie authentication, the the host of the index.html static file would implement cookie authentication.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Then how do u make your login ui and what if you have 2fa as well then in blazor is their components for that

0 Votes 0 ·
AgaveJoe avatar image AgaveJoe davidbuckley-4911 ·

Then how do u make your login ui and what if you have 2fa as well then in blazor is their components for that

Read the instructions for the identity service you are using.

ASP.NET Core Blazor authentication and authorization

The Core SDK has a hosted IdentityServer4 template that uses the Identity API and the Identity API has 2fa options.

 dotnet new blazorwasm -au Individual -ho -o {APP NAME}

Secure an ASP.NET Core Blazor WebAssembly hosted app with Identity Server



0 Votes 0 ·

So are you saying I run the scafold on the server project instead or do i not need it at all is there a good github example of this style u talk off.

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

Blazor client apps are a static web site. The blazor code can use HttpClient to call a login service to get a token (or use an iframe and host an open api login page).

to have a login server you create a separate asp.net core project to be the login server. you add this to the solution. as the blazor project is a static website, the server project can host, instead of a separate webserver.

you can manually deploy the blazor project to the server project wwwroot or use the new combined project (which nests the blazor project in the server project).

https://docs.microsoft.com/en-us/aspnet/core/blazor/security/webassembly/hosted-with-identity-server?view=aspnetcore-5.0&tabs=visual-studio

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.