Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7616501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:54:13+00:00 2026-05-31T02:54:13+00:00

In my mind these two bits of code should work the same: window.location =

  • 0

In my mind these two bits of code should work the same:

window.location = "../PlanView/ExportAsPDF";

$.ajax({
    url: '../PlanView/ExportAsPDF',
    data: { },
    success: function (stream) { window.location = stream; }
});

The former bit of code triggers a .PDF file download for the user. The second one does not — I have a weird request pending in my browser’s network traffic.

Could someone highlight the key differences here that I should be aware of?

More in-depth explanation:

I need to pass more data to my server than is allowed in a URL. As such, I need to POST to the server instead of GET. I cannot use the former code because I cannot shove that much information into a URL — the server will respond with 414.

I would like to replicate the functionality of the former bit of code with the latter.

public ActionResult ExportAsPDF(string dataURL)
{
    Document document = new Document(PageSize.A4.Rotate(), 15, 15, 30, 65); 

    byte[] buffer = new byte[0];
    using (MemoryStream memoryStream = new MemoryStream())
    {
        PdfWriter.GetInstance(document, memoryStream);

        document.Open();
        document.Add(new Paragraph("First PDF file"));
        document.Close();
        buffer = memoryStream.ToArray();
    }

    return File(buffer, "application/pdf", "PlanView.pdf");
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T02:54:14+00:00Added an answer on May 31, 2026 at 2:54 am

    The first one is different from the second because the first one tells the browser to display the file and the second one does not. Simply because “stream” won’t be “../PlanView/ExportAsPDF”.

    Also there’s no need for this ajax request if you just want to direct the browser to the file. Also the latter if it at all works, would give you what – binary contents of the PDF file? Frankly I wouldn’t know how to handle that 🙂

    You should also have “dataType” not “datatype” in your ajax attributes if you expect to get JSON back (which of course you won’t get).

    UPDATE:

    Even this should work:

    $.ajax({
    url: '../PlanView/ExportAsPDF',
    method : 'POST',
    data: { },
    dataType: 'json',
    success: function (stream) { window.location = '../PlanView/ExportAsPDF'; }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work with two branches of the same project. Both of them were created
I have these two tables: Table: ORDERS ID - NAME - DATA --------------------------------------------- 1
Is there a free source with basic yellow pages data(name,address, phone#)? I don't mind
How can I stack up these two opengl shapes into a container class? can
It is clear that the target is newer than the source from these two
I am having trouble understanding the difference between these two commands that in my
Let's say I have a list somewhere called majorPowers which contain these two lists:
Why did MS originally make the decision to maintain these two separate core libs?
For creating wordpress themes, people usually follow one of these two methods Design Mockup
update I added these two lines to the script below: I ran the debugger

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.