#### [Abblix\.Oidc\.Server\.Mvc](https://www.abblix.com/en/docs/api/abblix-oidc-server-mvc 'index')
### [Abblix\.Oidc\.Server\.Mvc](https://www.abblix.com/en/docs/api/abblix-oidc-server-mvc/Abblix.Oidc.Server.Mvc 'Abblix\.Oidc\.Server\.Mvc')

## MvcUtils Class

Provides utility methods for common MVC operations, including controller and action naming conventions,
parameter validation, and model state error handling\.

```csharp
public static class MvcUtils
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → MvcUtils
### Methods

## MvcUtils\.NameOf\<TController\>\(\) Method {#Abblix.Oidc.Server.Mvc.MvcUtils.NameOf_TController_()}

Retrieves the name of a controller type, removing the 'Controller' suffix\.

```csharp
public static string NameOf<TController>()
    where TController : Microsoft.AspNetCore.Mvc.ControllerBase;
```
#### Type parameters

###### `TController` {#Abblix.Oidc.Server.Mvc.MvcUtils.NameOf_TController_().TController}

The type of the controller\.

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')  
The name of the controller stripped of the 'Controller' suffix\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown if the controller's name does not follow the expected
            naming convention\.

### Remarks
This method is useful for generating controller names dynamically, such as when building URLs or
referencing controllers in logs\.

## MvcUtils\.Required\<T\>\(this T, string\) Method {#Abblix.Oidc.Server.Mvc.MvcUtils.Required_T_(thisT,string)}

Validates that an object is not null and satisfies the [Abblix\.Oidc\.Server\.Mvc\.MvcUtils\.RequiredAttribute](https://learn.microsoft.com/en-us/dotnet/api/abblix.oidc.server.mvc.mvcutils.requiredattribute 'Abblix\.Oidc\.Server\.Mvc\.MvcUtils\.RequiredAttribute') validation,
emulating model validation in ASP\.NET MVC\.

```csharp
public static T Required<T>(this T? value, string name)
    where T : class;
```
#### Type parameters

###### `T` {#Abblix.Oidc.Server.Mvc.MvcUtils.Required_T_(thisT,string).T}

The type of the object being validated\.
#### Parameters

###### `value` [T](https://www.abblix.com/en/docs/api/abblix-oidc-server-mvc/Abblix.Oidc.Server.Mvc.MvcUtils#Abblix.Oidc.Server.Mvc.MvcUtils.Required_T_(thisT,string).T 'Abblix\.Oidc\.Server\.Mvc\.MvcUtils\.Required\<T\>\(this T, string\)\.T') {#Abblix.Oidc.Server.Mvc.MvcUtils.Required_T_(thisT,string).value}

The object to validate\.

###### `name` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Mvc.MvcUtils.Required_T_(thisT,string).name}

The name of the parameter, used for error message formatting\.

#### Returns
[T](https://www.abblix.com/en/docs/api/abblix-oidc-server-mvc/Abblix.Oidc.Server.Mvc.MvcUtils#Abblix.Oidc.Server.Mvc.MvcUtils.Required_T_(thisT,string).T 'Abblix\.Oidc\.Server\.Mvc\.MvcUtils\.Required\<T\>\(this T, string\)\.T')  
The validated, non\-null object\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown if the object is null or does not satisfy
            the required validation\.

### Remarks
This method provides a programmatic way to enforce non\-nullability and validation of method parameters,
mimicking data annotations used in model classes\.

## MvcUtils\.TrimAsync\(string\) Method {#Abblix.Oidc.Server.Mvc.MvcUtils.TrimAsync(string)}

Removes the 'Async' suffix from the name of an asynchronous action method\.

```csharp
public static string TrimAsync(string action);
```
#### Parameters

###### `action` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Mvc.MvcUtils.TrimAsync(string).action}

The name of the action method\.

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')  
The action name without the 'Async' suffix\.

#### Exceptions

[System\.InvalidOperationException](https://learn.microsoft.com/en-us/dotnet/api/system.invalidoperationexception 'System\.InvalidOperationException')  
Thrown if the action's name does not end with 'Async' as per
            the naming convention\.

### Remarks
This method assists in referencing action methods by their logical names without the asynchronous operation
indicator\.
