跳到主要內容

C#WEB API 無法抓取檔名:Refused to get unsafe header “Content-Disposition”

開發檔案下載時,在測試機開發沒問題,上線後卻無法下載檔名。

開發工具顯示錯誤

Refused to get unsafe header "Content-Disposition"

看HTTP回復的資訊是有Content-Disposition,但是前端始終抓不到,後來查了一下原來API需要增加

response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition");

這樣子前端才可以抓地到這個欄位喔!!!!


Ref:https://dicksonkho.com/software-road/refused-to-get-unsafe-header-content-disposition/#comment-1854

留言

這個網誌中的熱門文章

[java]BIG5 字集判斷