Redigera

Dela via


HttpRequest.GetBufferlessInputStream Method

Definition

Gets a Stream object that can be used to read the incoming HTTP entity body.

Overloads

GetBufferlessInputStream()

Gets a Stream object that can be used to read the incoming HTTP entity body.

GetBufferlessInputStream(Boolean)

Gets a Stream object that can be used to read the incoming HTTP entity body, optionally disabling the request-length limit that is set in the MaxRequestLength property.

GetBufferlessInputStream()

Gets a Stream object that can be used to read the incoming HTTP entity body.

public:
 System::IO::Stream ^ GetBufferlessInputStream();
public System.IO.Stream GetBufferlessInputStream ();
member this.GetBufferlessInputStream : unit -> System.IO.Stream
Public Function GetBufferlessInputStream () As Stream

Returns

A Stream object that can be used to read the incoming HTTP entity body.

Exceptions

The request's entity body has already been loaded and parsed. Examples of properties that cause the entity body to be loaded and parsed include the following:

To avoid this exception, call the ReadEntityBodyMode method first. This exception is also thrown if the client disconnects while the entity body is being read.

Remarks

This method provides an alternative to using the InputStream property. The InputStream property waits until the whole request has been received before it returns a Stream object. In contrast, the GetBufferlessInputStream method returns the Stream object immediately. You can use the method to begin processing the entity body before the complete contents of the body have been received.

The entity body (or as much of it as you request and has been received) is returned only when you use the object that is returned by this method to read the stream, by calling methods such as the Read method. You use parameters of the Read method to specify how much of the entity body to read.

The Stream object returned by ASP.NET from this method supports both synchronous and asynchronous read methods. The Stream object implements both the BeginRead and EndRead methods. The asynchronous methods let you asynchronously read the request entity in chunks, while ASP.NET releases the current thread in between each iteration of an asynchronous read loop.

This method can be useful if the request is uploading a large file and you want to begin accessing the file contents before the upload is finished. However, you should only use this method for scenarios where you want to take over all processing of the entity body. This means that you cannot use this method from an .aspx page, because by the time an .aspx page runs, the entity body has already been read.

See also

Applies to

GetBufferlessInputStream(Boolean)

Gets a Stream object that can be used to read the incoming HTTP entity body, optionally disabling the request-length limit that is set in the MaxRequestLength property.

public:
 System::IO::Stream ^ GetBufferlessInputStream(bool disableMaxRequestLength);
public System.IO.Stream GetBufferlessInputStream (bool disableMaxRequestLength);
member this.GetBufferlessInputStream : bool -> System.IO.Stream
Public Function GetBufferlessInputStream (disableMaxRequestLength As Boolean) As Stream

Parameters

disableMaxRequestLength
Boolean

true to disable the request-length limit; otherwise, false.

Returns

A Stream object that can be used to read the incoming HTTP entity body.

Exceptions

The request's entity body has already been loaded and parsed. Examples of properties that cause the entity body to be loaded and parsed include the following:

To avoid this exception, call the ReadEntityBodyMode method first. This exception is also thrown if the client disconnects while the entity body is being read.

Remarks

For more information about this method, see the GetBufferlessInputStream() overload.

See also

Applies to