httpresponse with jquery and c#

Posted on 2012-09-10
Last Modified: 2012-09-10
I have the following:
var response = System.Web.HttpContext.Current.Response;
            response.AddHeader("Content-Type", "binary/octet-stream");
            response.AddHeader("Content-Disposition", "attachment; filename=PMSQuestionnaireResults.pdf; size=" + pdfBytes.Length.ToString());          

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:
%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

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

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!

Question by:scm0sml
    1 Comment
    LVL 17

    Accepted Solution

    You cannot use AJAX to download a file.

    See more details

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now