Dela via


HttpRequest Class

Definition

Represents the incoming side of an individual HTTP request.

public ref class HttpRequest abstract
public abstract class HttpRequest
type HttpRequest = class
Public MustInherit Class HttpRequest
Inheritance
HttpRequest

Constructors

HttpRequest()

Properties

Body

Gets or sets the request body Stream.

BodyReader

Gets the request body PipeReader.

ContentLength

Gets or sets the Content-Length header.

ContentType

Gets or sets the Content-Type header.

Cookies

Gets the collection of Cookies for this request.

Form

Gets or sets the request body as a form.

HasFormContentType

Checks the Content-Type header for form types.

Headers

Gets the request headers.

Host

Gets or sets the Host header. May include the port.

HttpContext

Gets the HttpContext for this request.

IsHttps

Returns true if the RequestScheme is https.

Method

Gets or sets the HTTP method.

Path

Gets or sets the portion of the request path that identifies the requested resource.

The value may be Empty if PathBase contains the full path, or for 'OPTIONS *' requests. The path is fully decoded by the server except for '%2F', which would decode to '/' and change the meaning of the path segments. '%2F' can only be replaced after splitting the path into segments.

PathBase

Gets or sets the base path for the request. The path base should not end with a trailing slash.

Protocol

Gets or sets the request protocol (e.g. HTTP/1.1).

Query

Gets the query value collection parsed from Request.QueryString.

QueryString

Gets or sets the raw query string used to create the query collection in Request.Query.

RouteValues

Gets the collection of route values for this request.

Scheme

Gets or sets the HTTP request scheme.

Methods

ReadFormAsync(CancellationToken)

Reads the request body if it is a form.

Extension Methods

GetMultipartBoundary(HttpRequest)

Gets the multipart boundary from the Content-Type header.

GetDisplayUrl(HttpRequest)

Returns the combined components of the request URL in a fully un-escaped form (except for the QueryString) suitable only for display. This format should not be used in HTTP headers or other HTTP operations.

GetEncodedPathAndQuery(HttpRequest)

Returns the relative URI.

GetEncodedUrl(HttpRequest)

Returns the combined components of the request URL in a fully escaped form suitable for use in HTTP headers and other HTTP operations.

GetTypedHeaders(HttpRequest)

Gets strongly typed HTTP request headers.

GetHeaderParsing(HttpRequest)

Gets the header parsing feature to access parsed header values.

TryGetHeaderValue<T>(HttpRequest, HeaderKey<T>, T, ParsingResult)

Tries to get a header value if it exists and can be parsed.

TryGetHeaderValue<T>(HttpRequest, HeaderKey<T>, T)

Tries to get a header value if it exists and can be parsed.

HasJsonContentType(HttpRequest)

Checks the Content-Type header for JSON types.

ReadFromJsonAsync(HttpRequest, JsonTypeInfo, CancellationToken)

Read JSON from the request and deserialize to object type. If the request's content-type is not a known JSON type then an error will be thrown.

ReadFromJsonAsync(HttpRequest, Type, JsonSerializerOptions, CancellationToken)

Read JSON from the request and deserialize to the specified type. If the request's content-type is not a known JSON type then an error will be thrown.

ReadFromJsonAsync(HttpRequest, Type, JsonSerializerContext, CancellationToken)

Read JSON from the request and deserialize to the specified type. If the request's content-type is not a known JSON type then an error will be thrown.

ReadFromJsonAsync(HttpRequest, Type, CancellationToken)

Read JSON from the request and deserialize to the specified type. If the request's content-type is not a known JSON type then an error will be thrown.

ReadFromJsonAsync<TValue>(HttpRequest, JsonSerializerOptions, CancellationToken)

Read JSON from the request and deserialize to the specified type. If the request's content-type is not a known JSON type then an error will be thrown.

ReadFromJsonAsync<TValue>(HttpRequest, JsonTypeInfo<TValue>, CancellationToken)

Read JSON from the request and deserialize to the specified type. If the request's content-type is not a known JSON type then an error will be thrown.

ReadFromJsonAsync<TValue>(HttpRequest, CancellationToken)

Read JSON from the request and deserialize to the specified type. If the request's content-type is not a known JSON type then an error will be thrown.

EnableBuffering(HttpRequest, Int32, Int64)

Ensure the requestBody can be read multiple times. Normally buffers request bodies in memory; writes requests larger than bufferThreshold bytes to disk.

EnableBuffering(HttpRequest, Int32)

Ensure the requestBody can be read multiple times. Normally buffers request bodies in memory; writes requests larger than bufferThreshold bytes to disk.

EnableBuffering(HttpRequest, Int64)

Ensure the requestBody can be read multiple times. Normally buffers request bodies in memory; writes requests larger than 30K bytes to disk.

EnableBuffering(HttpRequest)

Ensure the requestBody can be read multiple times. Normally buffers request bodies in memory; writes requests larger than 30K bytes to disk.

ReadFormAsync(HttpRequest, FormOptions, CancellationToken)

Read the request body as a form with the given options. These options will only be used if the form has not already been read.

CheckTrailersAvailable(HttpRequest)

Checks if the request supports trailers and they are available to be read now. This does not mean that there are any trailers to read.

GetDeclaredTrailers(HttpRequest)

Gets the request "Trailer" header that lists which trailers to expect after the body.

GetTrailer(HttpRequest, String)

Gets the requested trailing header from the response. Check SupportsTrailers(HttpRequest) or a NotSupportedException may be thrown. Check CheckTrailersAvailable(HttpRequest) or an InvalidOperationException may be thrown.

SupportsTrailers(HttpRequest)

Indicates if the request supports receiving trailer headers.

Applies to