Class ActionContextExtensions
- Namespace
- Htmx.Components.Extensions
- Assembly
- Htmx.Components.dll
Provides extension methods for IActionContextAccessor to ensure valid action contexts.
public static class ActionContextExtensions
- Inheritance
-
ActionContextExtensions
- Inherited Members
Methods
GetValidActionContext(IActionContextAccessor)
Provides a sanity check to fail early if IActionContextAccessor is not initialized
public static ActionContext GetValidActionContext(this IActionContextAccessor actionContextAccessor)
Parameters
actionContextAccessor
IActionContextAccessorThe action context accessor to validate.
Returns
- ActionContext
A valid ActionContext instance.
Remarks
This method performs comprehensive validation to ensure that all required components of the action context are available. It should be called before accessing any action context properties to prevent null reference exceptions.
Exceptions
- InvalidOperationException
Thrown when any of the following conditions are true:
- HttpContext is not available
- RouteData is not available
- ActionDescriptor is not available
- ArgumentNullException
Thrown when
actionContextAccessor
is null.