Can't get content-disposition from http.get header?

Viewed 6834

I am trying to download a file using web API + Angularjs and it's working fine, however I'm sending 'content-disposition' in the header from the web API but I'm unable to access it in the response-header.

WebAPI:

[HttpGet]
[AllowCrossSiteJson]
public HttpResponseMessage GetAcquisitionsTemplate()
{
    var docContent = _d.FirstOrDefault();
    Stream stream = new MemoryStream(docContent.Content);
    HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK);
    string contentDisposition = string.Concat("attachment; filename=", docContent.Name.Replace(" ", String.Empty), "." + docContent.Extension);
    result.Content = new StreamContent(stream);
    result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");    
    result.Content.Headers.ContentDisposition = ContentDispositionHeaderValue.Parse(contentDisposition);
    return result;            
}

Client Side (AngularJs):

$http.get(url)success(function (data, status, headers) {
    var header= headers();
})

In the header I'm getting the following values but I'm unable to get content-disposition. Please correct me where I'm wrong?

enter image description here

1 Answers
Related