質問編集履歴

5

OSやブラウザのバージョンを明記しました。

2017/07/08 04:13

投稿

ubon
ubon

スコア68

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
+ Window10 Pro 64bit バージョン 1703 OSビルド 15063.413
2
+
1
- Window10 64bit Chrome/IE11 VS2013 Community Update5環境において
3
+ Chrome/IE11 VS2013 Community Update5環境において
2
4
 
3
5
  CrystalReportsにてASP.NETのプログラムを作成しております。
4
6
 
@@ -12,7 +14,7 @@
12
14
 
13
15
  PDFをストリーム経由で(B)に出力するというプログラムを作成していたところ
14
16
 
15
- Chromeでは問題ないのですが、IE11では子ウインドウは開くものの
17
+ Chromeでは問題ないのですが、IE11(11.413.15063.0)では子ウインドウは開くものの
16
18
 
17
19
  画面が真っ白のまま読み込みが終了してしまいます。
18
20
 

4

開発環境について追記

2017/07/08 04:13

投稿

ubon
ubon

スコア68

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,6 @@
1
- Window10 64bit Chrome/IE11 VS2013 CrystalReportsにてASP.NETのプログラムを作成しております。
1
+ Window10 64bit Chrome/IE11 VS2013 Community Update5環境おい
2
+
3
+ CrystalReportsにてASP.NETのプログラムを作成しております。
2
4
 
3
5
 
4
6
 

3

注釈を追記しました。

2017/06/29 02:51

投稿

ubon
ubon

スコア68

test CHANGED
File without changes
test CHANGED
@@ -184,7 +184,7 @@
184
184
 
185
185
  ```
186
186
 
187
- <out.aspx.vb> ※out.aspxは特に編集無し
187
+ <out.aspx.vb> ※out.aspxは特に編集無し。sample.pdfは1ページの簡単なpdfを使用。
188
188
 
189
189
  ```lang-vb.net
190
190
 

2

サンプルコードを修正し、Fiddlerでのキャプチャ結果を追記いたしました。

2017/06/29 00:59

投稿

ubon
ubon

スコア68

test CHANGED
File without changes
test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
  関係ないと判断しております。その根拠としては
38
38
 
39
- Windows7環境ではChrome/IE11ともに動作確認済みのrptファイルと
39
+ Windows7環境ではChrome/IE11ともに動作確認済みのrptファイルと
40
40
 
41
41
  PDF出力のロジックをそのまま利用して、window.openの部分を切り替えることによって
42
42
 
@@ -44,71 +44,281 @@
44
44
 
45
45
 
46
46
 
47
+ ---
48
+
49
+ **2017.06.29 コードを修正しました。**
50
+
51
+ base.aspxをスタートアップとし、baseにあるボタンから、out.aspxでストリーム出力させるサンプルコードです。
52
+
53
+ <base.aspx> base.aspx.vbファイルは編集無し
54
+
55
+ ```lang-aspx
56
+
57
+ <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="base.aspx.vb" Inherits="WebApplication1.base" %>
58
+
59
+
60
+
61
+ <!DOCTYPE html>
62
+
63
+
64
+
65
+ <html xmlns="http://www.w3.org/1999/xhtml">
66
+
67
+ <head runat="server">
68
+
69
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
70
+
71
+ <meta http-equiv="content-language" content="ja" />
72
+
73
+ <meta http-equiv="x-ua-compatible" content="IE=10" />
74
+
75
+ <meta http-equiv="x-ua-compatible" content="IE=EmulateIE10" />
76
+
77
+ <title>output test</title>
78
+
79
+ <script src="jquery.min.js" type="text/javascript"></script>
80
+
81
+
82
+
83
+ <script type="text/javascript">
84
+
85
+ $(function () {
86
+
87
+
88
+
89
+ $('#btn_ok').click(function () {
90
+
91
+
92
+
93
+ window.open('out.aspx?type=hist&rpt_hidP=' + 'dummy', '_blank');
94
+
95
+
96
+
97
+ });
98
+
99
+
100
+
101
+ $('#btn_dame').click(function () {
102
+
103
+
104
+
105
+ window.open('', 'report');
106
+
107
+
108
+
109
+ var form = $('<form/>', {
110
+
111
+ id: 'rpt_p',
112
+
113
+ action: 'out.aspx?type=hist',
114
+
115
+ target: 'report',
116
+
117
+ method: 'post'
118
+
119
+ }).append($('<input/>').attr({
120
+
121
+ type: 'hidden',
122
+
123
+ id: 'rpt_hidP',
124
+
125
+ name: 'rpt_hidP',
126
+
127
+ value: 'dummy'
128
+
129
+ })
130
+
131
+ );
132
+
133
+
134
+
135
+ $('body').append(form);
136
+
137
+
138
+
139
+ $('#rpt_p').submit();
140
+
141
+ $('#rpt_p').remove();
142
+
143
+
144
+
145
+ form = null;
146
+
147
+
148
+
149
+ });
150
+
151
+
152
+
153
+ });
154
+
155
+ </script>
156
+
157
+ </head>
158
+
159
+ <body>
160
+
161
+ <form id="form1" runat="server">
162
+
47
- うまくいかないパターン
163
+ <div>
164
+
165
+
166
+
167
+ <input type="button" id="btn_ok" value="OKパターン" />
168
+
169
+
170
+
171
+ <input type="button" id="btn_dame" value="ダメパターン" />
172
+
173
+
174
+
175
+ </div>
176
+
177
+ </form>
178
+
179
+ </body>
180
+
181
+ </html>
182
+
183
+
184
+
185
+ ```
186
+
187
+ <out.aspx.vb> ※out.aspxは特に編集無し
188
+
189
+ ```lang-vb.net
190
+
191
+ Imports System
192
+
193
+ Imports System.IO
194
+
195
+
196
+
197
+ Public Class out
198
+
199
+ Inherits System.Web.UI.Page
200
+
201
+
202
+
203
+ Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
204
+
205
+
206
+
207
+ Response.Cache.SetCacheability(HttpCacheability.NoCache)
208
+
209
+ Response.Cache.SetNoStore()
210
+
211
+
212
+
213
+ Dim bLength As Byte()
214
+
215
+
216
+
217
+ 'ファイルを開く
218
+
219
+ Dim fs As New System.IO.FileStream(HttpContext.Current.Server.MapPath("pdf/sample.pdf"), System.IO.FileMode.Open, System.IO.FileAccess.Read)
220
+
221
+
222
+
223
+ 'ファイルを読み込むバイト型配列を作成する
224
+
225
+ ReDim bLength(fs.Length)
226
+
227
+ 'ファイルの内容をすべて読み込む
228
+
229
+ fs.Read(bLength, 0, Convert.ToInt32(bLength.Length))
230
+
231
+ '閉じる
232
+
233
+ fs.Close()
234
+
235
+
236
+
237
+ Response.ClearHeaders()
238
+
239
+ Response.ClearContent()
240
+
241
+ Response.ContentType = "Application/pdf"
242
+
243
+
244
+
245
+ ' ダイアログ表示
246
+
247
+ Response.AddHeader("content-disposition", "inline; filename=" & System.Web.HttpUtility.UrlEncode("sample.pdf"))
248
+
249
+
250
+
251
+ ' HTTP 出力ストリームに書き込み
252
+
253
+ Response.BinaryWrite(bLength)
254
+
255
+ Response.End()
256
+
257
+
258
+
259
+ End Sub
260
+
261
+
262
+
263
+ End Class
264
+
265
+ ```
266
+
267
+ OKパターン ボタン 結果
268
+
269
+ Windows10 64bit Chrome ○ **IE11 ○**
270
+
271
+ Windows7 32bit Chrome ○ IE11 ○
272
+
273
+
274
+
275
+ ダメパターン ボタン 結果
48
276
 
49
277
  Windows10 64bit Chrome ○ **IE11 ×**
50
278
 
51
279
  Windows7 32bit Chrome ○ IE11 ○
52
280
 
281
+
282
+
53
- ```javascript
283
+ 上記のサンプルでも再現することからもrptは関係ないと思われます。
54
-
284
+
285
+
286
+
55
- window.open('', 'report');
287
+ さらに、SurferOnWwwさんからアドバイスいただいたようにFiddlerでキャプチャした結果
288
+
289
+
290
+
56
-
291
+ OKパターンのキャプチャ
57
-
58
-
292
+
59
- var form = $('<form/>', {
293
+ リクエストヘッダー GET /out?type=hist&rpt_hidP=dummy HTTP/1.1
60
-
294
+
61
- id: 'rpt_p',
295
+ レスポンスヘッダー HTTP/1.1 200 OK
296
+
297
+
298
+
62
-
299
+ ダメパターンのキャプチャ
300
+
63
- action: 'out_pdf.aspx?type=hist',
301
+ リクエストヘッダー POST /out.aspx?type=hist HTTP/1.1
64
-
65
- target: 'report',
302
+
66
-
67
- method: 'post'
68
-
69
- }).append($('<input/>').attr({
303
+ レスポンスヘッダー HTTP/1.1 301 Moved Permanently となり下記のような
70
-
71
- type: 'hidden',
304
+
72
-
73
- id: 'rpt_hidP',
74
-
75
- name: 'rpt_hidP',
76
-
77
- value: $('#hidP').val()
305
+ HTMLが出力された後 Location: /out?type=hist でリダイレクトされているという違いが明らかになりました。
78
-
306
+
79
- })
307
+ ```html
80
-
308
+
81
- );
309
+ <html><head><title>Object moved</title></head><body>
310
+
82
-
311
+ <h2>Object moved to <a href="/out?type=hist">here</a>.</h2>
83
-
84
-
312
+
85
- $('body').append(form);
313
+ </body></html>
86
-
87
-
88
-
89
- $('#rpt_p').submit();
90
-
91
- $('#rpt_p').remove();
92
-
93
-
94
-
95
- form = null;
96
-
97
-
98
314
 
99
315
  ```
100
316
 
101
- うまくいくパターン
317
+
102
-
318
+
103
- Windows10 64bit Chrome ○ **IE11 ○**
319
+ Chromeでも同様のキャプチャ結果となりましたが、動作しております。
104
-
105
- Windows7 32bit Chrome ○ IE11 ○
320
+
106
-
107
- ```javascript
321
+
108
-
109
- window.open('out_pdf.aspx?type=hist&rpt_hidP=' + $.trim($('#hidP').val()), '_blank');
110
-
111
- ```
112
322
 
113
323
  パラメータが多くなる可能性があるため、できればPOSTで解決したいと
114
324
 

1

具体的なサンプルコードを掲載しました。

2017/06/29 00:29

投稿

ubon
ubon

スコア68

test CHANGED
File without changes
test CHANGED
@@ -32,6 +32,84 @@
32
32
 
33
33
 
34
34
 
35
+ 本件CrystalReportsは記載させていただいておりますが
36
+
37
+ 関係ないと判断しております。その根拠としては
38
+
39
+ Windows7環境ではChrome/IE11ともに動作確認済みのrptファイルと
40
+
41
+ PDF出力のロジックをそのまま利用して、window.openの部分を切り替えることによって
42
+
43
+ 現象が発生するかしないかが切り替わることを確認したためです。
44
+
45
+
46
+
47
+ うまくいかないパターン
48
+
49
+ Windows10 64bit Chrome ○ **IE11 ×**
50
+
51
+ Windows7 32bit Chrome ○ IE11 ○
52
+
53
+ ```javascript
54
+
55
+ window.open('', 'report');
56
+
57
+
58
+
59
+ var form = $('<form/>', {
60
+
61
+ id: 'rpt_p',
62
+
63
+ action: 'out_pdf.aspx?type=hist',
64
+
65
+ target: 'report',
66
+
67
+ method: 'post'
68
+
69
+ }).append($('<input/>').attr({
70
+
71
+ type: 'hidden',
72
+
73
+ id: 'rpt_hidP',
74
+
75
+ name: 'rpt_hidP',
76
+
77
+ value: $('#hidP').val()
78
+
79
+ })
80
+
81
+ );
82
+
83
+
84
+
85
+ $('body').append(form);
86
+
87
+
88
+
89
+ $('#rpt_p').submit();
90
+
91
+ $('#rpt_p').remove();
92
+
93
+
94
+
95
+ form = null;
96
+
97
+
98
+
99
+ ```
100
+
101
+ うまくいくパターン
102
+
103
+ Windows10 64bit Chrome ○ **IE11 ○**
104
+
105
+ Windows7 32bit Chrome ○ IE11 ○
106
+
107
+ ```javascript
108
+
109
+ window.open('out_pdf.aspx?type=hist&rpt_hidP=' + $.trim($('#hidP').val()), '_blank');
110
+
111
+ ```
112
+
35
113
  パラメータが多くなる可能性があるため、できればPOSTで解決したいと
36
114
 
37
115
  考えております。