ApiKeyException Class
Definition
- Namespace
- Cuemon.AspNetCore.Http.Headers
- Assemblies
- Cuemon.AspNetCore.dll
The exception that is thrown when the requirements of an API key header is not meet.
public class ApiKeyException : HttpStatusCodeException, ISerializable
- Inheritance
-
objectApiKeyException
- Implements
- Inherited Members
Examples
The following example demonstrates how a is used to signal that a request's API key header validation failed.
using System;
using Microsoft.AspNetCore.Http;
namespace Cuemon.AspNetCore.Http.Headers;
public static class ApiKeyExceptionExample
{
public static void Demonstrate()
{
var exception = new ApiKeyException(StatusCodes.Status403Forbidden, "The API key was rejected.");
Console.WriteLine($"{exception.StatusCode} {exception.ReasonPhrase}");
}
}
Constructors
| Name | Description |
|---|---|
| ApiKeyException(int, string) | Initializes a new instance of the ApiKeyException class. |