0
プロジェクトに取り組んでいて、新しいタブでpdfを表示する必要があります。byte[]
としてレポートサービスからpdfを取得するコントローラーがあります。私は、コントローラ呼び出すためのAjaxを使用しています新しいウィンドウでコントローラーから返されたPDFストリームを表示する
var data = Search(search_info);
var stream = new MemoryStream(data, 0, data.Length, true, true);
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "filename=\"\"" + "caseoverview" + ".pdf" + "");
Response.ContentType = MimeTypes.ApplicationPdf;
Response.OutputStream.Write(data1, 0, Convert.ToInt32(stream.Length));
Response.Flush();
return new FileStreamResult(stream, "application/pdf");
:
function OnCompleteMethod(dataq, status) {
if (status === "success") {
var w = window.open("data:application/pdf, " + escape(dataq.responseText));
w.document.write(dataq.responseText);
w.document.close();
}
}
そして、これは私が新しいタブで取得していますものです:
@using (Ajax.BeginForm("Search", "Controller", null,
new AjaxOptions
{
HttpMethod = "post",
OnComplete = "OnCompleteMethod",
OnFailure = "OnFailtureMethod"
}))
{
<div id="query-filter" class="filters">
@Html.Partial("QueryFilter", Model)
</div>
<div class="row">
<div class="col-md-2 col-sm-6 col-md-offset-8">
<button class="btn btn-submit btn-block" type="submit">Find</button>
</div>
<div class="col-md-2 col-sm-6">
<button class="btn btn-submit btn-block" type="reset">Reset</button>
</div>
</div>
}
と成功の方法のためのjavascriptです:
誰かがこの問題を手伝ってくれて、私が間違ってやっていることや解決策に欠けていることを説明することができますか?
ありがとうございました。