Table of Contents

UserAgentException Class

Definition

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

public class UserAgentException : HttpStatusCodeException, ISerializable
Inheritance
object
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

Name Description
UserAgentException(int, string)

Initializes a new instance of the UserAgentException class.

See Also