Table of Contents

Class UserAgentSentinelOptions

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

Configuration options for UserAgentSentinelMiddleware and related.

public class UserAgentSentinelOptions : IValidatableParameterObject, IParameterObject
Inheritance
UserAgentSentinelOptions
Implements

Constructors

UserAgentSentinelOptions()

Initializes a new instance of the UserAgentSentinelOptions class.

public UserAgentSentinelOptions()

Remarks

The following table shows the initial property values for an instance of UserAgentSentinelOptions.

PropertyInitial Value
AllowedUserAgentsnew List{string}();
BadRequestMessageThe requirements of the request was not met.
ForbiddenMessageThe HTTP User-Agent specified was rejected.
RequireUserAgentHeaderfalse
ValidateUserAgentHeaderfalse
ResponseHandlerA HttpResponseMessage initialized to either a HTTP status code 400 or 403 and a body of either BadRequestMessage or ForbiddenMessage.
UseGenericResponsefalse

Properties

AllowedUserAgents

Gets or sets a list of whitelisted user agents.

public IList<string> AllowedUserAgents { get; set; }

Property Value

IList<String>

A list of whitelisted user agents.

BadRequestMessage

Gets or sets the message of a request missing the requirements of a User-Agent header.

public string BadRequestMessage { get; set; }

Property Value

String

The message of a request missing the requirements of a User-Agent header.

ForbiddenMessage

Gets or sets the message of a request without a valid User-Agent header.

public string ForbiddenMessage { get; set; }

Property Value

String

The message of a request without a valid User-Agent header.

RequireUserAgentHeader

Gets or sets a value indicating whether a HTTP User-Agent header must be present in the request.

public bool RequireUserAgentHeader { get; set; }

Property Value

Boolean

true if the HTTP User-Agent header must be present in the request; otherwise, false.

ResponseHandler

Gets or sets the function delegate that configures the response in the form of a HttpResponseMessage.

public Func<string, HttpResponseMessage> ResponseHandler { get; set; }

Property Value

Func<String, HttpResponseMessage>

The function delegate that configures the response in the form of a HttpResponseMessage.

UseGenericResponse

Gets or sets a value indicating whether the produced ResponseHandler should be as neutral as possible.

public bool UseGenericResponse { get; set; }

Property Value

Boolean

true if the produced ResponseHandler should be as neutral as possible; otherwise, false.

ValidateUserAgentHeader

Gets or sets a value indicating whether a HTTP User-Agent header must be validated against AllowedUserAgents.

public bool ValidateUserAgentHeader { get; set; }

Property Value

Boolean

true if the HTTP User-Agent header must be validated against AllowedUserAgents; otherwise, false.

Methods

ValidateOptions()

Determines whether the public read-write properties of this instance are in a valid state.

public void ValidateOptions()

Remarks

This method is expected to throw exceptions when one or more conditions fails to be in a valid state.

Exceptions

InvalidOperationException

ResponseHandler cannot be null - or - AllowedUserAgents cannot be null.