Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Unrecognized attribute 'role' on child content element 'Authorized'

I’m getting the error from the title when i try to use the role attribute on the Authorized element in Blazor.
It worked earlier this day. I haven’t changed anything actively regarding this.

This is a minimalistic test razor compoment where it does’t work.

<h3>Test</h3>

<AuthorizeView Roles="test,prod">
    <Authorized role="test">

    </Authorized>
    <Authorized role="prod">

    </Authorized>
</AuthorizeView>

@code {

}

Google didn’t help me on that case.
Any idea would be appreciated!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Environment:
VS 2022
Blazor
Win 10
.NET 7

>Solution :

Authorized does not work like this I’m afraid. The role property you are seeing is unrelated and can be added to most razor tags, and specifies the visual role of the element, and isn’t associated with Authorization.

If you want to have two separate views for test and prod I’d suggest simply having two AuthorizeView tags, like the following:

<AuthorizeView Roles="test">
    <Authorized>

    </Authorized>
</AuthorizeView>
<AuthorizeView Roles="prod">
    <Authorized>

    </Authorized>
</AuthorizeView>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading