32

ファイルをアップロードして、ファイルのプロパティ (名前、サイズなど) に関する json 応答を返そうとしています。IE 以外のすべてのブラウザで正常に動作します。

IE は JSON をファイルとしてダウンロードしようとします。

私はIE10を持っていて、ブラウザモードとドキュメントモードをデバッガから変更してIE7から10でテストしています。

私はasp.net mvc4を使用しています。ファイルアップロードアクションにはHttpPost属性があり、return Json(myObject);を使用してjson応答を返しています。

そして、ここに私のhttpヘッダーがあります

リクエスト

Key Value
Request POST /File/UploadFile/ HTTP/1.1
Accept  text/html, application/xhtml+xml, */*
Referer http://localhost:63903/
Accept-Language en-NZ
User-Agent  Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Content-Type    multipart/form-data; boundary=---------------------------7dc1e71330526
Accept-Encoding gzip, deflate
Host    localhost:63903
Content-Length  1377002
DNT 1
Connection  Keep-Alive
Cache-Control   no-cache

応答

Key Value
Response    HTTP/1.1 200 OK
Server  ASP.NET Development Server/11.0.0.0
Date    Tue, 18 Dec 2012 23:44:19 GMT
X-AspNet-Version    4.0.30319
X-AspNetMvc-Version 4.0
Cache-Control   private
Content-Type    application/json; charset=utf-8
Content-Length  154
Connection  Close

私はいくつかの提案を試みましたが、今のところ振り出しに戻っています!

4

2 に答える 2

46

text/htmlIEはコンテンツをどうするか分からないので、jsonを返す必要がありapplication/jsonます..

return Json(myObject, "text/html");

確かではありませんが、使用するとうまくいく可能性があります(うまくいくとより正確になりますtext/x-json

return Json(myObject, "text/x-json");
于 2012-12-19T01:20:56.980 に答える