Table of Contents

Class UserAgentException

Namespace
Cuemon.AspNetCore.Http.Headers
Assembly
Cuemon.AspNetCore.dll

The exception that is thrown when the requirements of an HTTP User-Agent header is not meet.

public class UserAgentException : HttpStatusCodeException, ISerializable
Inheritance
UserAgentException
Implements
Inherited Members

Examples

The following example demonstrates how a is used to signal that a request's User-Agent header was rejected.

using System;
using Microsoft.AspNetCore.Http;

        namespace Cuemon.AspNetCore.Http.Headers;

        public static class UserAgentExceptionExample
        {
            public static void Demonstrate()
            {
                var exception = new UserAgentException(StatusCodes.Status400BadRequest, "The User-Agent header is required.");
        Console.WriteLine($"{exception.StatusCode} {exception.ReasonPhrase}");
            }
        }

Constructors

UserAgentException(int, string)

Initializes a new instance of the UserAgentException class.

public UserAgentException(int statusCode, string message)

Parameters

statusCode int

The HTTP status code to associate with this exception.

message string

The message that describes the HTTP status code.

See Also