Aspnetcore.docs: Add two sections with details about scaffolding into server-side blazor apps

Created on 11 Nov 2019  ·  18Comments  ·  Source: dotnet/AspNetCore.Docs

With auth.
Without auth.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Blazor P2 doc-enhancement

Most helpful comment

@mkArtakMSFT I've researched this a bit more. The issue that I opened (and just closed) at #16944 is a dup of this issue, so I'm going to work the scenarios from here.

I took a look at the scaffolding topic at ...

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.1&tabs=visual-studio

... and it's similar ... the steps are about the same, but that topic so RP/MVC-ish (code and markup examples), that I think we'd be better served by placing the Blazor scaffolding into Blazor's auth topic (probably less attracive) or creating a new topic for it in the Blazor TOC (probably the better choice). Conversely, the current scaffolding topic would need work to make it more generic so that it would apply to all three scenarios (RP, MVC, and Blazor).

🤔 Your thoughts?

All 18 comments

Since I'm not currently aware of any difference for scaffolding into a Blazor Server app (configured for auth from the template or without) over a web app, I'll need more guidance to work this. Let's put it on the Blazor.Docs project for more info when this is triaged.

Related: https://github.com/aspnet/AspNetCore/issues/16972

@guardrex wait until https://github.com/aspnet/AspNetCore/issues/16972 closes and then create the doc off the readme.

... and cross-link from ASP.NET Core Blazor authentication and authorization (with clarity that this is for Blazor Server).

@javiercn what details are you interested in here to be covered?

@javiercn @mkArtakMSFT bot closing due to lack of information.

Running the Identity scaffold on Blazor server Core 3.1 does not work. I created a new Server app with local identity in my SQL database. The error is "Scheme already exists: Identity.Application".

We really need instructions for Blazor for 1) run the scaffolding, 2) create ApplicationUser custom class, and 3) change the UserId in database from nvarchar(450) to Guid. BTW, the use of nvarchar(450) prevents the ability to use compound primary keys.

Ainda não conseguimos utilizar 'Scaffold Identity' com Blazor, mesmo na versão .NET Core 3.1.
Alguma previsão?

@VR-Architect

The error is "Scheme already exists: Identity.Application".

That has nothing to do with Blazor. I've seen that error when you create a new web app with authorization, register a user, then scaffold.

Drop the DB, run update and try again.
Verify that Areas\Identity\IdentityHostingStartup.cs doesn't have a duplicate AddDefaultIdentity call.

change the UserId in database from nvarchar(450) to Guid.

See Identity model customization in ASP.NET Core

Is it possible to add an example with some custom Identity provider implementation?
For example this can be useful:
https://github.com/Robynhu/AspNetCore.Identity.PostgreSQL
It uses PostgreSQL as a user storage and does not use EF. No any Migrations etc, only creation db structure by script.

@mkArtakMSFT I've researched this a bit more. The issue that I opened (and just closed) at #16944 is a dup of this issue, so I'm going to work the scenarios from here.

I took a look at the scaffolding topic at ...

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.1&tabs=visual-studio

... and it's similar ... the steps are about the same, but that topic so RP/MVC-ish (code and markup examples), that I think we'd be better served by placing the Blazor scaffolding into Blazor's auth topic (probably less attracive) or creating a new topic for it in the Blazor TOC (probably the better choice). Conversely, the current scaffolding topic would need work to make it more generic so that it would apply to all three scenarios (RP, MVC, and Blazor).

🤔 Your thoughts?

creating a new topic for it in the Blazor TOC (probably the better choice).

That gets my non-counting vote. I think that's better than adding Blazor to the existing doc.

Yeah ... it's gonna be a fight to get it in there .... looks a bit overhaul-ish to make that work and avoid lots of duplication in that topic (i.e., if just sections are added). If we go with a little Blazor version of it over here, I can work it right after those high priority Blazor docs issues get worked, and those go forward right after the current crop of PRs merge.

@guardrex I think having a generic identity scaffolding topic is fine, and for the Blazor TOC, we can have a tiny writeup, where we can say something like "The auth for Blazor Server is exactly what it is for MVC and/or RP, so please look into there (link here) for how to scaffold identity).

@Rick-Anderson Scaffold Identity is one of your 👶. Resolving this issue might require significant structural and content changes to the topic. I only looked briefly, but that was my impression given the examples and markup shown. Do you want me to go ahead and stomp around in there 🐾, or would you prefer to work this one?

@guardrex can't you just add a Blazor section outlining what needs to be done? Do we need a complete walk through like I provided for MVC/RP?

I can try. I have a feeling that there will be a lot of duplication with what you have there. The current guidance is about right for Blazor ... it's just that all of the examples/markup aren't the same.

Let's do that ... I'll try it with only sections and see how it composes. If it starts to go badly tho ... hitting problems ... I'll ping back here with it for further discussion.

@bdnts ... I've finally come to a day that I can dedicate to this one. Thanks for your notes over on https://github.com/dotnet/aspnetcore/issues/19148.

I think I see what I'd like to do on the PR with this to get the ball rolling with basic coverage that we can revise and extend thereafter. I'll ping you on the PR, which should land this evening.

You spoke about converting some number of page-based auth endpoints over to Razor components. Idk what the design will be later for that ... will they make a set of component-based auth endpoints for the OOB experience? I'll :pray: to the server gods for it! ... but I'd like to link a set of components from a Blazor node sample folder attached to the topic ... not show them ... just cross-link a set of them. Potentially, it could save a massive number of developer hours. If you have a set, would you be willing to provide them?

I understand from your notes that the Login page presents a major challenge, and I get that devs have been using an API-based approach for that. Those points are probably worth mentioning because devs are going to want to know what's possible today. Did you ultimately work out a SignalR approach? If not, which approach did you land on?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danroth27 picture danroth27  ·  3Comments

Rick-Anderson picture Rick-Anderson  ·  3Comments

Raghumu picture Raghumu  ·  3Comments

serpent5 picture serpent5  ·  3Comments

wgutierrezr picture wgutierrezr  ·  3Comments