#### [Abblix\.Utils](https://www.abblix.com/en/docs/api/abblix-utils 'index')
### [Abblix\.Utils](https://www.abblix.com/en/docs/api/abblix-utils/Abblix.Utils 'Abblix\.Utils')

## HttpServerUtility Class

Provides utility methods for encoding and decoding URL tokens\.

```csharp
public static class HttpServerUtility
```

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

## HttpServerUtility\.UrlTokenDecode\(string\) Method {#Abblix.Utils.HttpServerUtility.UrlTokenDecode(string)}

Decodes a URL token into a byte array\.

```csharp
public static byte[] UrlTokenDecode(string input);
```
#### Parameters

###### `input` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Utils.HttpServerUtility.UrlTokenDecode(string).input}

The URL token to decode\.

#### Returns
[System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array')  
A byte array representing the decoded data\.

### Remarks
This method converts URL\-safe characters \('\-' and '\_'\) back to their
original Base64 equivalents \('\+' and '/'\) and then decodes the Base64 string\.

## HttpServerUtility\.UrlTokenEncode\(byte\[\], Nullable\<int\>\) Method {#Abblix.Utils.HttpServerUtility.UrlTokenEncode(byte[],System.Nullable_int_)}

Encodes a byte array into a URL token\.

```csharp
public static string UrlTokenEncode(byte[]? input, System.Nullable<int> length=null);
```
#### Parameters

###### `input` [System\.Byte](https://learn.microsoft.com/en-us/dotnet/api/system.byte 'System\.Byte')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.Utils.HttpServerUtility.UrlTokenEncode(byte[],System.Nullable_int_).input}

The byte array to encode\.

###### `length` [System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1') {#Abblix.Utils.HttpServerUtility.UrlTokenEncode(byte[],System.Nullable_int_).length}

The number of bytes to encode\. If null, encodes the entire array\.

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')  
A URL\-safe token representing the encoded data\.

#### Exceptions

[System\.ArgumentOutOfRangeException](https://learn.microsoft.com/en-us/dotnet/api/system.argumentoutofrangeexception 'System\.ArgumentOutOfRangeException')  
Thrown when the specified length is greater than the actual length of the input array\.

### Remarks
This method first converts the byte array to a Base64 string, then replaces Base64\-specific
characters \('\+' and '/'\) with URL\-safe characters \('\-' and '\_'\), and trims any trailing '=' characters\.
