Class ApiKeyException
- Namespace
- Cuemon.AspNetCore.Http.Headers
- Assembly
- 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
-
ApiKeyException
- 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
ApiKeyException(int, string)
Initializes a new instance of the ApiKeyException class.
public ApiKeyException(int statusCode, string message)
Parameters
statusCodeintThe HTTP status code to associate with this exception.
messagestringThe message that describes the HTTP status code.