The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HttpContentHeaderCollection.ContentDisposition | contentDisposition property

Applies to Windows and Windows Phone

Gets or sets the HttpContentDispositionHeaderValue object that represents the value of an HTTP Content-Disposition header on the HTTP content.


var contentDisposition = httpContentHeaderCollection.contentDisposition;
httpContentHeaderCollection.contentDisposition = contentDisposition;

Property value

Type: HttpContentDispositionHeaderValue

The object that represent the value of HTTP Content-Disposition header on the HTTP content. A null value means that the header is absent.


The following sample code shows a method to get or set the Content-Disposition header value on HTTP content using the ContentDisposition property on the HttpContentHeaderCollection object.

    // Content-Disposition header
    // HttpContentDispositionHeaderValue
    void DemoContentDisposition(IHttpContent content) {
        var h = content.Headers;

        HttpContentDispositionHeaderValue value;
        bool ok = HttpContentDispositionHeaderValue.TryParse("attachment; filename=\"myfile.txt\"; myparam=myvalue", out value);
        h.ContentDisposition = value;

        h.ContentDisposition = HttpContentDispositionHeaderValue.Parse("attachment; filename=\"myfile.txt\"; myparam=myvalue");
        var header = h.ContentDisposition;

        uiLog.Text += "\nCONTENT DISPOSITION HEADER\n";
        // Content-Disposition: attachment; filename="fname.ext"

        // ContentDisposition is a HttpContentDispositionHeaderValue and contains:
        // DispositionType, FileName, FileNameStar, Name: all strings
        // Size: nullable long
        // Parameters: IList<HttpNameValueHeaderValue> 
        var parameterString = "";
        foreach (var parameter in header.Parameters) {
            parameterString += string.Format("[{0}={1}] ", parameter.Name, parameter.Value);
        if (parameterString == "") {
            parameterString = "(no parameters)";

        uiLog.Text += string.Format("ContentDisposition: DispositionType: {0} FileName: {1} FileNameStar: {2} Name: {3} Parameters: {4} Size: {5} ToString: {6}\n\n", 
        header.DispositionType, header.FileName, header.FileNameStar, header.Name, parameterString, header.Size, header.ToString());


Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


Windows::Web::Http::Headers [C++]



See also




© 2014 Microsoft