Francesco Iapicca
Francesco Iapicca

Reputation: 2647

Can't Locate Razor Pages in Default Blazor Server Side Project

(super beginner alert)

in the "default" Blazor server side project with built in Login the LoginDisplay.razor file contains

<AuthorizeView>
<Authorized>
    <a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
    <form method="post" action="Identity/Account/LogOut">
        <button type="submit" class="nav-link btn btn-link">Log out</button>
    </form>
</Authorized>
<NotAuthorized>
    <a href="Identity/Account/Register">Register</a>
    <a href="Identity/Account/Login">Log in</a>
</NotAuthorized>

let's take as example "Identity/Account/Register":

if I look into the "Identity" Area the only pages I find are

"Account" and "Shared"; none of which contains the aforementioned page.

what am I missing?

thank you

[edit] Following Chris Sainty answer (thank you)

but I'm experiencing this:

https://github.com/aspnet/AspNetCore/issues/13120

trying this solution

The steps, based on a Preview8 server-side project with "Individual user accounts" :

  • temporarily disable this line in Startup: // endpoints.MapBlazorHub(selector: "app");
  • run the scaffolding wizzard, add any pages you want
  • uncomment the endpoints.MapBlazorHub() line again
  • remove Pages/_ViewStart.cshtml
  • fix Pages/Shared/_Layout.cshtml, the first line is missing @using
  • fix Pages/Shared/_Loginpartial.cshtml, the second line is missing @inject

Upvotes: 3

Views: 2221

Answers (1)

Chris Sainty
Chris Sainty

Reputation: 8521

If you want to customise the Identity pages you have to scaffold them out first.

Say you want to customise the Register page, you would right click on your project and select:

Add > Scaffolded Item > Select Identity from the left menu and then click OK.

You'll then get a list of all the available pages and you can select which ones you want to override. Once you've done this the files will appear in your project and you can customise them as usual.

Upvotes: 3

Related Questions