Skip to content

ControllerExtensions ​

The ControllerExtensions class provides extension methods for ASP.NET Core controllers. It adds convenient helper methods that can be called directly on instances of ControllerBase or Controller.


Methods ​

IsUserAuthenticated ​

csharp
public static bool IsUserAuthenticated(this ControllerBase controller)

Description: Checks whether the current user associated with the controller’s HttpContext is authenticated.

Parameters:

  • controller (ControllerBase): The controller instance to check authentication for.

Returns:true if the user is authenticated; otherwise, false.