1

Trying to establish user accounts in my blazor web assembly app and build an element of authentication.

However, two components have the error:

Found markup element with unexpected name 'xxxxxxxxxxxxxxxx'

The two problematic components are AuthorizeRouteView and CascadingAuthenticationState.

My code:

<Router AppAssembly="@typeof(Program).Assembly">
    <Found Context="routeData">
        <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
    </Found>
    <NotFound>
        <CascadingAuthenticationState>
            <LayoutView Layout="@typeof(MainLayout)">
                <p>Sorry, there's nothing at this address.</p>
            </LayoutView>
        </CascadingAuthenticationState>
    </NotFound>
</Router>

Any clue what might be wrong?

dros
  • 1,217
  • 2
  • 15
  • 31

1 Answers1

0

Try the following setting. Note that within the NotAuthorized property element is an element named RedirectToLogin. This is the name of a Razor component you should define (RedirectToLogin.razor file name), and may need to update its namespace in the _Imports.razor file( for instance: @using OpenIDConnectSample.Shared).

<CascadingAuthenticationState>
    <Router AppAssembly="@typeof(Program).Assembly">
        <Found Context="routeData">
            <AuthorizeRouteView RouteData="@routeData" 
                             DefaultLayout="@typeof(MainLayout)">
                <NotAuthorized>
                    <RedirectToLogin />
                </NotAuthorized>
                <Authorizing>
                    Wait...
                </Authorizing>
            </AuthorizeRouteView>
        </Found>
        <NotFound>
            <LayoutView Layout="@typeof(MainLayout)">
                <p>Sorry, there's nothing at this address.</p>
            </LayoutView>
        </NotFound>
    </Router>
</CascadingAuthenticationState>
enet
  • 41,195
  • 5
  • 76
  • 113