Table of Contents

Class AttributeNavProvider

Namespace
Htmx.Components.NavBar
Assembly
Htmx.Components.dll

Navigation provider that discovers navigation actions through NavActionAttribute and NavActionGroupAttribute attributes on controller actions.

public class AttributeNavProvider : INavProvider
Inheritance
AttributeNavProvider
Implements
Inherited Members
Extension Methods

Examples

To use attribute-based navigation, mark controller actions with navigation attributes:

[NavActionGroup(DisplayName = "User Management", Order = 10)]
public class UserController : Controller
{
    [NavAction(DisplayName = "Users", Icon = "fas fa-users", Order = 1)]
    public IActionResult Index() { ... }

    [NavAction(DisplayName = "Roles", Icon = "fas fa-shield", Order = 2)]
    public IActionResult Roles() { ... }
}

Remarks

This provider automatically scans all controller actions for navigation attributes and builds a navigation structure based on the discovered actions. Actions are filtered based on the current user's authorization permissions before being included in the navigation.

Constructors

AttributeNavProvider(IActionDescriptorCollectionProvider, IAuthorizationService, IHttpContextAccessor, IServiceProvider, IAuthorizationMetadataService)

Initializes a new instance of the AttributeNavProvider class.

public AttributeNavProvider(IActionDescriptorCollectionProvider actions, IAuthorizationService authorizationService, IHttpContextAccessor httpContextAccessor, IServiceProvider serviceProvider, IAuthorizationMetadataService authMetadataService)

Parameters

actions IActionDescriptorCollectionProvider

The action descriptor collection provider for discovering controller actions.

authorizationService IAuthorizationService

The authorization service for checking user permissions.

httpContextAccessor IHttpContextAccessor

The HTTP context accessor for accessing request context.

serviceProvider IServiceProvider

The service provider for dependency resolution.

authMetadataService IAuthorizationMetadataService

The authorization metadata service for extracting authorization information.

Exceptions

ArgumentNullException

Thrown when any parameter is null.

Methods

BuildAsync()

Builds the navigation action set by discovering and filtering controller actions.

public Task<IActionSet> BuildAsync()

Returns

Task<IActionSet>

A task that represents the asynchronous operation. The task result contains the navigation action set.