开发者

cannot save pdf in IE

开发者 https://www.devze.com 2023-03-18 07:11 出处:网络
I am able to download and save other types of files in Internet Explorer and I am able to download and save pdf types in Firefox.But in IE8, I cannot download a pdf file.I\'ve checked the wcf code, it

I am able to download and save other types of files in Internet Explorer and I am able to download and save pdf types in Firefox. But in IE8, I cannot download a pdf file. I've checked the wcf code, it is returning a file stream and as I've already mentioned, it does work on other types of files, like .xlsx.

Here is my form on the html page

<div>
  <form id="frmdownloadData" action="http://localhost:9433/NASWcf1/runDownloadFile" 
     method="post" enctype="multipart/form-data" target="_blank">
  <input type="hidden" id="UserId" name="UserId" value="****" />
  File Name: <input id="filename" name="filename" type="text" value=""/>
  <br />
  App Code: <input id="appcode" name="appcode" type="text" value="Appcode_FileId"  />
  </form>
</div>
<input type="button" id="submitdwnldfrm" onclick="dofileDownload()" />

here is the script for the dofileDownload()

function dofileDownload() {
        $('#frmdownloadData').ajaxSubmit(function () {
            alert("Thank you 开发者_Python百科for your comment!");
        });
    }

Befopre returning the file stream from the wcf, I set this property: System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.ContentType = "application/octet-stream";

I've also tried setting it to "application/pdf" but it doesn't help.

any help would be appreciated.


found a solution: Set the ContentType = "application/x-unknown" then add this header "Content-Disposition: attachment; filename=filename.ext;"

Sample code below:

System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.ContentType   = "application/x-unknown";
                System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.Headers.Add("Content-Disposition: attachment; filename="+filename+";");
0

精彩评论

暂无评论...
验证码 换一张
取 消