7
Web API + Angularjsを使用してファイルをダウンロードしようとしていますが、うまくいきますが、Web APIのヘッダーに「content-disposition」を送信していますが、レスポンスヘッダーでアクセスできません。http.getヘッダーからコンテンツの処理を取得できませんか?
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;
}
クライアント側(AngularJs):ヘッダで
$http.get(url)success(function (data, status, headers) {
var header= headers();
})
私は、次の値を取得していますが、私は、コンテンツ配置を取得できませんよ。私が間違っているところで私を修正してください?
これは、レールのバックエンドで行う方法です。http://jaketrent.com/post/expose-http-headers-in-コルス/ –