2016-08-03 47 views
0

重複請求我有一個MVC的行動,被稱爲如下:MVC FilePathResult行動導致在Chrome

http://localhost/Report/PrintContainerMasterTrayList?containerMasterId=x&type=downloadview

行動具有以下簽名

public ActionResult PrintContainerInstanceTrayList(int containerInstanceId, string type) 

這如下返回FilePathResult

return File(filename, "application/pdf"); 

這是除了Chrome中的請求觸發兩次外,沒有任何問題。該請求僅在Firefox和IE11中進行一次。

原始請求

GET http://localhost/DEV-SAF/Report/PrintContainerMasterTrayList?containerMasterId=x&type=downloadview HTTP/1.1 Host: localhost Connection: keep-alive Cache-Control: max-age=0 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 Accept-Encoding: gzip, deflate, sdch Accept-Language: en-GB,en;q=0.8 Cookie: .ASPXANONYMOUS=-

的第二請求

GET http://localhost/DEV-SAF/Report/PrintContainerMasterTrayList?containerMasterId=x&type=downloadview HTTP/1.1 Host: localhost Connection: keep-alive User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36 Accept: */* Referer: http://localhost/DEV-SAF/Report/PrintContainerMasterTrayList?containerMasterId=x&type=downloadview Accept-Encoding: gzip, deflate, sdch Accept-Language: en-GB,en;q=0.8

從兩個請求的響應是相同的(在這種情況下達到一個4Mb的文件,該文件正在使用過多的帶寬)。

是什麼導致了這種行爲?

編輯

從第一請求的響應是 HTTP/1.1 200 OK Cache-Control: private, s-maxage=0 Content-Type: application/pdf Server: Microsoft-IIS/10.0 Set-Cookie: .AUTH=xxxxxx; path=/; HttpOnly X-AspNetMvc-Version: 5.2 Date: Wed, 03 Aug 2016 14:17:41 GMT Content-Length: 3999

從第二請求的響應是 HTTP/1.1 200 OK Cache-Control: private, s-maxage=0 Content-Type: application/pdf Server: Microsoft-IIS/10.0 X-AspNetMvc-Version: 5.2 Date: Wed, 03 Aug 2016 14:17:46 GMT Content-Length: 3999

+0

請求粘貼的內容不相同,例如在查詢字符串中比較containerMasterId = 94101和containerMasterId = x –

+0

對不起,這是我的複製和粘貼。編輯帖子。 – Fishcake

+0

這兩個請求是一起開火還是一個開火? –

回答

0

嘗試內容處置頭添加到響應你的行動與以下內容爲「附件;文件名= test.pdf」或者簡稱「附件」

Response.AppendHeader("Content-Disposition", "attachment"); 
+0

這確實會阻止請求進行兩次,但僅向用戶提供下載對話框,並且我們希望瀏覽器顯示PDF。 – Fishcake

+0

它看起來像一個已知的鉻pdf插件的bug:https://bugs.chromium.org/p/chromium/issues/detail?id=587709 可能dublicate http://stackoverflow.com/questions/1817750/do-大多數瀏覽器使多個http請求當顯示一個pdf從內部t –

+0

我只是回來評論,我懷疑鉻插件感謝找到鉻錯誤。 – Fishcake

相關問題