The day before yesterday, I added display content for both authenticated and unauthenticated users in Blog.razor. However, if the unauthenticated content to be displayed is the same across the system, writing it in every Component is a waste of time. We can use App.razor to handle this unified presentation.
First, delete the <AuthorizeView> that originally wrapped the content in Blog.razor, cut the <NotAuthorized> section, and add the line @attribute [Authorize] to inform Blazor that this Component requires authentication.

Then, change the single tag in App.razor to paired tags, paste the previously cut <NotAuthorized>, and restart the website. The content seen by unauthenticated users will be the same.

Currently, any authenticated user can see the same Component, but most systems usually have roles or permission divisions to distinguish different users. Tomorrow, we will try to use Role to differentiate authorization.
Note: The code in this article has been refactored using .NET 6 + Visual Studio 2022. You can click the original link to compare with the refactored code. Thank you for reading and supporting the original author.