Class UnsupportedMediaTypeException
- Namespace
- Cuemon.AspNetCore.Http
- Assembly
- 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
-
UnsupportedMediaTypeException
- 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
UnsupportedMediaTypeException()
Initializes a new instance of the UnsupportedMediaTypeException class.
public UnsupportedMediaTypeException()
UnsupportedMediaTypeException(Exception)
Initializes a new instance of the UnsupportedMediaTypeException class.
public UnsupportedMediaTypeException(Exception innerException)
Parameters
innerExceptionExceptionThe exception that is the cause of the current exception.
UnsupportedMediaTypeException(string, Exception)
Initializes a new instance of the UnsupportedMediaTypeException class.
public UnsupportedMediaTypeException(string message, Exception innerException = null)
Parameters
messagestringThe message that describes the HTTP status code.
innerExceptionExceptionThe exception that is the cause of the current exception.