开发者

cannot save pdf in IE

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜