Then the nav link is set to active as expected, likewise, the isActive style is applied. When the user clicks My Profile react redirects to their profile. If interested the code for the component is on GitHub. In my menu, I have a navigation link- My Profile. Make sure and check out the official AuthorizeView component docs for more details. AuthrozieView has the advantage of not being limited to page component.Īlso, note that AuthorizeView also supports roles and policies. specify the activeClassName prop on the component with its value.While the Authorize attribute is still very useful Iâm sure that the AuthorizeView will be getting a lot of use in Blazor apps. Bootstrap Navbar Toggle ShowHide design by Clint Bettiga is very creative and. Äo note that you should still use the Authorize attribute on the page that should require authorization and not depend on the menu item being hidden keeping users from finding the page. To hide menu item we wrap the list item in the AuthorizeView component. The following code is the code that renders the Fetch data menu item which is the section we want to hide if the user isnât logged in. In the Pages/Shared directory open the NavMenu.razor file which is the file where the nav menu is defined. This is going to be a quick post showing how the AuthorizedView component can be used to hide any content that a user should be logged in to see (or be in a specific role). ![]() While the authorize attribute does keep the user from viewing the contents of the page it still allows the user access to the nav menu item for the page they arenât authorized to access. There are 100 anchor tags in my html page with class nav-link i want to hide first 95 and show only last 5 after page load.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |