HttpMultipartFormDataContent HttpMultipartFormDataContent HttpMultipartFormDataContent HttpMultipartFormDataContent Class

Provides HTTP content that uses the multipart/form-data MIME type.

Syntax

Declaration

public sealed class HttpMultipartFormDataContentpublic sealed class HttpMultipartFormDataContentPublic NotInheritable Class HttpMultipartFormDataContent

Remarks

Enumerating the collection in C# or Microsoft Visual Basic

You can iterate through a HttpMultipartFormDataContent object in C# or Microsoft Visual Basic. In many cases, such as using foreach syntax, the compiler does this casting for you and you won't need to cast to IEnumerable<IHttpContent> explicitly. If you do need to cast explicitly, for example if you want to call GetEnumerator, cast to IEnumerable<T> with an IHttpContent constraint.

Constructors summary

Initializes a new instance of the HttpMultipartFormDataContent class.

Initializes a new instance of the HttpMultipartFormDataContent class with the specified boundary string.

Properties summary

Get a collection of content headers set on the HttpMultipartFormDataContent.

Methods summary

Add HTTP content to the HttpMultipartFormDataContent instance.

Add HTTP content with a specified name to the HttpMultipartFormDataContent instance.

Add HTTP content with a specified name from a file to the HttpMultipartFormDataContent instance.

Serialize the HttpMultipartFormDataContent into memory as an asynchronous operation.

Closes the HttpMultipartFormDataContent instance and releases allocated resources.

Gets an object that can be used to enumerate the contents in the HttpMultipartFormDataContent object.

Serialize the HttpMultipartFormDataContent to a buffer as an asynchronous operation.

Serialize the HttpMultipartFormDataContent and return an input stream that represents the content as an asynchronous operation.

Serialize the HttpMultipartFormDataContent to a String as an asynchronous operation.

Returns a string that represents the current HttpMultipartFormDataContent object.

Determines whether the HttpMultipartFormDataContent has a valid length in bytes.

Write the HttpMultipartFormDataContent to an output stream as an asynchronous operation.

Constructors

  • HttpMultipartFormDataContent()
    HttpMultipartFormDataContent()
    HttpMultipartFormDataContent()
    HttpMultipartFormDataContent()

    Initializes a new instance of the HttpMultipartFormDataContent class.

    public HttpMultipartFormDataContent()public HttpMultipartFormDataContent()Public Function HttpMultipartFormDataContent() As
  • HttpMultipartFormDataContent(System.String)
    HttpMultipartFormDataContent(System.String)
    HttpMultipartFormDataContent(System.String)
    HttpMultipartFormDataContent(System.String)

    Initializes a new instance of the HttpMultipartFormDataContent class with the specified boundary string.

    public HttpMultipartFormDataContent(System.String boundary)public HttpMultipartFormDataContent(System.String boundary)Public Function HttpMultipartFormDataContent(boundary As System.String) As

    Parameters

    • boundary
      System.String
      System.String
      System.String
      System.String

      The boundary string for the multipart content.

Properties

Methods

  • Add(Windows.Web.Http.IHttpContent)
    Add(Windows.Web.Http.IHttpContent)
    Add(Windows.Web.Http.IHttpContent)
    Add(Windows.Web.Http.IHttpContent)

    Add HTTP content to the HttpMultipartFormDataContent instance.

    public void Add(Windows.Web.Http.IHttpContent content)public void Add(Windows.Web.Http.IHttpContent content)Public Function Add(content As Windows.Web.Http.IHttpContent) As void

    Parameters

  • Add(Windows.Web.Http.IHttpContent,System.String)
    Add(Windows.Web.Http.IHttpContent,System.String)
    Add(Windows.Web.Http.IHttpContent,System.String)
    Add(Windows.Web.Http.IHttpContent,System.String)

    Add HTTP content with a specified name to the HttpMultipartFormDataContent instance.

    public void Add(Windows.Web.Http.IHttpContent content,System.String name)public void Add(Windows.Web.Http.IHttpContent content,System.String name)Public Function Add(content As Windows.Web.Http.IHttpContent,name As System.String) As void

    Parameters

  • Add(Windows.Web.Http.IHttpContent,System.String,System.String)
    Add(Windows.Web.Http.IHttpContent,System.String,System.String)
    Add(Windows.Web.Http.IHttpContent,System.String,System.String)
    Add(Windows.Web.Http.IHttpContent,System.String,System.String)

    Add HTTP content with a specified name from a file to the HttpMultipartFormDataContent instance.

    public void Add(Windows.Web.Http.IHttpContent content,System.String name,System.String fileName)public void Add(Windows.Web.Http.IHttpContent content,System.String name,System.String fileName)Public Function Add(content As Windows.Web.Http.IHttpContent,name As System.String,fileName As System.String) As void

    Parameters

  • BufferAllAsync()
    BufferAllAsync()
    BufferAllAsync()
    BufferAllAsync()

    Serialize the HttpMultipartFormDataContent into memory as an asynchronous operation.

    public IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync()public IAsyncOperationWithProgress<ulong, ulong> BufferAllAsync()Public Function BufferAllAsync() As IAsyncOperationWithProgress( Of ulong, ulong )

    Returns

    • The object that represents the asynchronous operation.

    Remarks

    This operation will not block. The returned IAsyncOperationWithProgress<TResult, TProgress> object will complete after all of the content has been written into memory.

    The HttpMultipartFormDataContent class can be used to stream content that might be of arbitrary length. The BufferAllAsync() method will fail if all of the HttpMultipartFormDataContent can't fit in memory.

  • Close()
    Close()
    Close()
    Close()

    Closes the HttpMultipartFormDataContent instance and releases allocated resources.

    public void Close()public void Close()Public Function Close() As void

    Remarks

    The Close() method releases allocated resources used by the HttpMultipartFormDataContent instance. The Close() method can manage the lifetime of system resources (memory for the HttpMultipartFormDataContent, for example) used by a Windows Runtime object.

    In the .NET Framework 4.5, this method projects as the Dispose method. In Visual C++ component extensions (C++/CX), this method projects as the destructor (delete operator).

    Apps written in JavaScript, C#, or VB.NET use garbage collection to release resources. So the Close() object and associated resources doesn't get released until the garbage collection pass runs. The Close() method allows an app to release these resources early rather than waiting for the object to be released by garbage collection.

    Apps written in C++ or CX don't have a Close() method since these apps can destroy the object. In C++ and CX, objects are released when they fall out of program scope or as part of the destructor (delete operator) for the object.

  • First()
    First()
    First()
    First()

    Gets an object that can be used to enumerate the contents in the HttpMultipartFormDataContent object.

    public IIterator<IHttpContent> First()public IIterator<IHttpContent> First()Public Function First() As IIterator( Of IHttpContent )

    Returns

  • ReadAsBufferAsync()
    ReadAsBufferAsync()
    ReadAsBufferAsync()
    ReadAsBufferAsync()

    Serialize the HttpMultipartFormDataContent to a buffer as an asynchronous operation.

    public IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync()public IAsyncOperationWithProgress<IBuffer, ulong> ReadAsBufferAsync()Public Function ReadAsBufferAsync() As IAsyncOperationWithProgress( Of IBuffer, ulong )

    Returns

    • The object representing the asynchronous operation.

    Remarks

    This operation will not block. The returned IAsyncOperationWithProgress<TResult, TProgress> object will complete after all of the content has been written to the buffer.

    The HttpMultipartFormDataContent class can be used to stream content that might be of arbitrary length. The ReadAsBufferAsync() method will fail if all of the HttpMultipartFormDataContent can't fit in memory since this method requires the entire content to be buffered in memory first.

  • ReadAsInputStreamAsync()
    ReadAsInputStreamAsync()
    ReadAsInputStreamAsync()
    ReadAsInputStreamAsync()

    Serialize the HttpMultipartFormDataContent and return an input stream that represents the content as an asynchronous operation.

    public IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync()public IAsyncOperationWithProgress<IInputStream, ulong> ReadAsInputStreamAsync()Public Function ReadAsInputStreamAsync() As IAsyncOperationWithProgress( Of IInputStream, ulong )

    Returns

    • The object representing the asynchronous operation.

    Remarks

    This operation will not block. The returned IAsyncOperationWithProgress<TResult, TProgress> object will complete after all of the content has been written to the stream.

  • ReadAsStringAsync()
    ReadAsStringAsync()
    ReadAsStringAsync()
    ReadAsStringAsync()

    Serialize the HttpMultipartFormDataContent to a String as an asynchronous operation.

    public IAsyncOperationWithProgress<string, ulong> ReadAsStringAsync()public IAsyncOperationWithProgress<string, ulong> ReadAsStringAsync()Public Function ReadAsStringAsync() As IAsyncOperationWithProgress( Of string, ulong )

    Returns

    • The object representing the asynchronous operation.

    Remarks

    This operation will not block. The returned IAsyncOperationWithProgress<TResult, TProgress> object will complete after all of the content has been written to the String.

    The HttpMultipartFormDataContent class can be used to stream content that might be of arbitrary length. The ReadAsStringAsync() method will fail if all of the HttpMultipartFormDataContent can't fit in memory since this method requires the entire content to be buffered in memory first.

  • ToString()
    ToString()
    ToString()
    ToString()

    Returns a string that represents the current HttpMultipartFormDataContent object.

    public string ToString()public string ToString()Public Function ToString() As string

    Returns

    • string
      string
      string
      string

      A string that represents the current object.

  • TryComputeLength(System.UInt64)
    TryComputeLength(System.UInt64)
    TryComputeLength(System.UInt64)
    TryComputeLength(System.UInt64)

    Determines whether the HttpMultipartFormDataContent has a valid length in bytes.

    public bool TryComputeLength(System.UInt64 length)public bool TryComputeLength(System.UInt64 length)Public Function TryComputeLength(length As System.UInt64) As bool

    Parameters

    Returns

    • bool
      bool
      bool
      bool

      true if length is a valid length; otherwise, false.

    Remarks

    The TryComputeLength(System.UInt64) method calculates the content length for HTTP content in HttpMultipartFormDataContent. Headers set on the content are not included in the content length. This is useful for content types that are easy to calculate the content length.

    If computing the content length is not possible or expensive (would require the system to buffer the whole content where the serialization would be expensive or require the system to allocate a lot of memory), this method can return false. If this method returns false, this implies that either chunked transfer is needed or the content must get buffered before being sent to the server.

  • WriteToStreamAsync(Windows.Storage.Streams.IOutputStream)
    WriteToStreamAsync(Windows.Storage.Streams.IOutputStream)
    WriteToStreamAsync(Windows.Storage.Streams.IOutputStream)
    WriteToStreamAsync(Windows.Storage.Streams.IOutputStream)

    Write the HttpMultipartFormDataContent to an output stream as an asynchronous operation.

    public IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(Windows.Storage.Streams.IOutputStream outputStream)public IAsyncOperationWithProgress<ulong, ulong> WriteToStreamAsync(Windows.Storage.Streams.IOutputStream outputStream)Public Function WriteToStreamAsync(outputStream As Windows.Storage.Streams.IOutputStream) As IAsyncOperationWithProgress( Of ulong, ulong )

    Parameters

    Returns

    • The object that represents the asynchronous operation.

    Remarks

    This operation will not block. The returned IAsyncOperationWithProgress<TResult, TProgress> object will complete after all of the content has been written to the output stream.

Attributes

Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ActivatableAttribute

Details

Assembly

Windows.Web.Http.dll