• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 731
  • Last Modified:

httpresponse with jquery and c#

I have the following:
var response = System.Web.HttpContext.Current.Response;
            response.Clear();
            response.AddHeader("Content-Type", "binary/octet-stream");
            response.AddHeader("Content-Disposition", "attachment; filename=PMSQuestionnaireResults.pdf; size=" + pdfBytes.Length.ToString());          
            response.Flush();
            response.BinaryWrite(pdfBytes);
            response.Flush();
            response.End();

This is exporting a pdf that I have created and works fine.

I wanted to call the function that does this though with jquery.

This is now broken.

When I check the response in firebug I see:
%PDF-1.4
%¿¿¿¿
%Created by Wnv/EP PDF Tools v8.0
1 0 obj
<<
/Pages 2 0 R
/PageLayout /OneColumn
/PageMode /UseNone
/ViewerPreferences 3 0 R
/Type /Catalog
>>

endobj
2 0 obj
<<
/Count 2
/Kids [4 0 R 5 0 R]
/Type /Pages
>>

endobj
4 0 obj
<<
/Resources <<
/ProcSet [/PDF /Text /ImageC]
/XObject <<
/NAME_njifnhheinnmklihpcigknpdilkojllb 6 0 R
/NAME_himklphdmcenkdchpjfgnldlngmlkijm 7 0 R

Open in new window


Seems to be the content of the pdf?

Is there a way around this?

I could use a swift reply on this!

Thanks
0
scm0sml
Asked:
scm0sml
1 Solution
 
sonawanekiranCommented:
You cannot use AJAX to download a file.


See more details
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now