Skip to main content

StreamingRequest.Body property

The request body as a read-only, forward-only stream.

public Stream Body { get; }

Remarks​

Read it with ReadAsync or CopyToAsync; a read returns 0 at the end of the body. The synchronous Read throws NotSupportedException, and so do Length, Position and Seek. Await each read before starting the next.

Cancelling the token passed to a pending read cancels its host operation and throws OperationCanceledException. A read throws IOException when the host cannot deliver the body, including a pending read left after response completion.

The handler need not read the whole body. Content it has not read when it returns its response is not read at all, and a read still waiting then throws IOException.

See Also​