UnsupportedMediaTypeException Class
Definition
- Namespace
- Cuemon.AspNetCore.Http
- Assemblies
- Cuemon.AspNetCore.dll
The exception that is thrown when the media format of the requested data is not supported by the server, so the server is rejecting the request.
public class UnsupportedMediaTypeException : HttpStatusCodeException, ISerializable
- Inheritance
-
objectUnsupportedMediaTypeException
- Implements
- Inherited Members
Examples
The following example demonstrates how to return an UnsupportedMediaTypeException when the API receives an unsupported file upload format.
using System;
using Cuemon.AspNetCore.Http;
namespace MyApp.Examples;
public class UnsupportedMediaTypeExceptionExample
{
public void Demonstrate()
{
try
{
throw new UnsupportedMediaTypeException("text/html");
}
catch (UnsupportedMediaTypeException ex)
{
Console.WriteLine(ex.StatusCode); // 415
}
}
}
Constructors
| Name | Description |
|---|---|
| UnsupportedMediaTypeException() | Initializes a new instance of the UnsupportedMediaTypeException class. |
| UnsupportedMediaTypeException(Exception) | Initializes a new instance of the UnsupportedMediaTypeException class. |
| UnsupportedMediaTypeException(string, Exception) | Initializes a new instance of the UnsupportedMediaTypeException class. |