Table of Contents

Class NotAcceptableException

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

The exception that is thrown when the web server, after performing server-driven content negotiation, does not find any content that conforms to the criteria given by the user agent.

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

Examples

The following example demonstrates how to configure an ASP.NET Core MVC filter that returns a NotAcceptableException.

using System;

namespace Cuemon.AspNetCore.Http;

public static class NotAcceptableExceptionExample
{
    public static void Demonstrate()
    {
        var acceptHeader = "application/xml";
        var exception = new NotAcceptableException($"The endpoint cannot produce '{acceptHeader}'.");

        Console.WriteLine(exception.Message);
        Console.WriteLine(exception.StatusCode);
    }
}

Constructors

NotAcceptableException()

Initializes a new instance of the NotAcceptableException class.

public NotAcceptableException()

NotAcceptableException(Exception)

Initializes a new instance of the NotAcceptableException class.

public NotAcceptableException(Exception innerException)

Parameters

innerException Exception

The exception that is the cause of the current exception.

NotAcceptableException(string, Exception)

Initializes a new instance of the MethodNotAllowedException class.

public NotAcceptableException(string message, Exception innerException = null)

Parameters

message string

The message that describes the HTTP status code.

innerException Exception

The exception that is the cause of the current exception.

See Also