NotAcceptableException Class
Definition
- Namespace
- Cuemon.AspNetCore.Http
- Assemblies
- 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
-
objectNotAcceptableException
- 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
| Name | Description |
|---|---|
| NotAcceptableException() | Initializes a new instance of the NotAcceptableException class. |
| NotAcceptableException(Exception) | Initializes a new instance of the NotAcceptableException class. |
| NotAcceptableException(string, Exception) | Initializes a new instance of the MethodNotAllowedException class. |