Table of Contents

PreconditionRequiredException Class

Definition

The exception that is thrown when the origin server requires the request to be conditional.

public class PreconditionRequiredException : HttpStatusCodeException, ISerializable
Inheritance
object
PreconditionRequiredException
Implements
Inherited Members

Examples

The following example demonstrates how to use PreconditionRequiredException when a request requires conditional headers.

using System;

namespace Cuemon.AspNetCore.Http;

public static class PreconditionRequiredExceptionExample
{
    public static void Demonstrate()
    {
        var hasConditionHeader = false;
        var exception = hasConditionHeader
            ? new PreconditionRequiredException()
            : new PreconditionRequiredException("Supply an If-Match header before retrying the update.");

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

Constructors

Name Description
PreconditionRequiredException()

Initializes a new instance of the PreconditionRequiredException class.

PreconditionRequiredException(Exception)

Initializes a new instance of the PreconditionRequiredException class.

PreconditionRequiredException(string, Exception)

Initializes a new instance of the PreconditionRequiredException class.

See Also