画面にpdfを書き込もうとしているページがあります。これが私がやっていることです:
protected void ViewPDF(string url)
{
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.TransmitFile(url);
Response.Flush();
Response.End();
}
これは、Mac 上の Firefox を除くすべてのブラウザーと OS で機能します。ブラウザーに pdf ファイルを表示する代わりに、ブラウザーはファイルをダウンロードするためのダイアログを開きます。ファイルを開くか保存することができます。
私もこれを試しました:
protected void ViewPDF(string url)
{
Response.Clear();
Response.ContentType = "application/pdf";
string path = Server.MapPath(url);
byte[] data = File.ReadAllBytes(path);
Response.BinaryWrite(data);
Response.End();
}
そして、私は同じ結果を得ます。
誰でもこれを修正する方法を知っていますか?