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

  • SEARCH
  • Home
  • 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 174859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:35:52+00:00 2026-05-11T13:35:52+00:00

Response.Write(<script language=\javascript\>window.open( with https and pdf What we do in a Asp.Net 1.1.4332 application

  • 0
Response.Write('<script language=\'javascript\'>window.open( with https and pdf 

What we do in a Asp.Net 1.1.4332 application is the following:

a button triggers a server event that does some processing and puts the data in a session object after that the following code is executed :

string page = Request.ApplicationPath + '/ApkRapportPage.aspx';     Response.Write('<script language=\'javascript\'>window.open('' + page + '','_new');</script>'); 

this opens a page that streams a pdf to the new browser window

basically with the following code ( I know stuff is missing here, but that doesn’t really mater for the question)

byte[] pdfbytes = Convert.FromBase64String(rapportB64);

Response.ClearContent(); Response.ClearHeaders(); Response.Buffer = true; Response.ContentType = GetContentType(format); string header = GetContentDispostionHeader(fileName, format, type); Response.AddHeader('Content-Disposition', header); Response.BinaryWrite(pdfbytes);          Response.End(); 

Okay this code works !

Just not in IE6 and IE7 when using HTTPS

When using IE6 with HTTPS it results in a save-as dialog (not a pdf that opens in a browser) When using IE7 with HTTPS it results in a blank screen When using Firefox it works just fine

If I simulate the extra server side processing in the page_load to put the required data in the session and replace the button with a link that opens the same pdf generating page in a new window, the code works.

For the actual application it is not an option to get the required data before the button is clicked.

So I would really like to get the following code to work

string page = Request.ApplicationPath + '/ApkRapportPage.aspx';     Response.Write('<script language=\'javascript\'>window.open('' + page + '','_new');</script>'); 

Questions: Does anybody know why this code doesn’t work in IE6 and IE7 when using HTTPS ? What is needed to get the code to work ?

Extra info:

  • I tried not using response.write but just a javascript window.open behind the button, this has the same effect
  • when googling for pdf streaming, you can find a lot of people having trouble with this, mostly they set header lengths or other properties or static file compression flags in IIS. I am pretty confident I tried them all.
  • Adobe acrobat reader settings, browser settings or any other client side settings don’t seem to be the problem. Tested on different machines, with http works, with https it doesn’t.
  • Switching between https and http might have something to do with this, but when I set IE to tell me when I am switching, no switching seems to occur during testing.
  • When replacing the window.open part with a response.redirect then the code also works, just not in a new window

Any help would be greatly appreciated !


As requested the headers, as shown by Fiddler:

   HTTP/1.1 200 OK    Server: Microsoft-IIS/5.1    Date: Thu, 05 Mar 2009 14:18:36 GMT    X-Powered-By: ASP.NET    X-AspNet-Version: 1.1.4322    Content-Disposition: Inline;filename=APKrapport.pdf    Cache-Control: private    Content-Type: application/pdf; charset=utf-8    Content-Length: 28307 
  • 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. 2026-05-11T13:35:52+00:00Added an answer on May 11, 2026 at 1:35 pm

    After a lot of trial and error I found a working solution, still not sure why the other code doesn’t work.

    This code works:

    StringBuilder js = new StringBuilder('<script language=\'javascript\'>'); js.Append('_window = window.open(\'\','_new');'); js.Append('_window.document.open(\'application/pdf\');'); js.Append('_window.location.href = \'ApkRapportPage.aspx\';');   js.Append('_window.document.close();'); js.Append('</script>');  Response.Write(js.ToString()); 

    Must have something to do with the mime type.

    It has a problem though. When IE is set to show when you switch between HTTP and HTTPS this code will give that message twice. The following code doesn’t switch but causes the page load of ApkRapportPage to be fired twice.

    StringBuilder js = new StringBuilder('<script language=\'javascript\'>'); js.Append('_window = window.open(\'ApkRapportPage.aspx\','_new');'); js.Append('_window.document.open(\'application/pdf\');'); js.Append('_window.location.href = \'ApkRapportPage.aspx\';');   js.Append('_window.document.close();'); js.Append('</script>');  Response.Write(js.ToString()); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A quick 'n dirty way to get the actual heap… May 11, 2026 at 11:56 pm
  • Editorial Team
    Editorial Team added an answer What you are looking for is a reverse proxy and… May 11, 2026 at 11:56 pm
  • Editorial Team
    Editorial Team added an answer According to this post, the 'Notes' data isn't accessible via… May 11, 2026 at 11:56 pm

Related Questions

I have an ASPX page where I am uploading an image to server for
I'm looking to somehow get jQuery inserted into every page with the MINIMUM of
I need a client-side script to confirm that the Timer's OnTick event can proceed.
Why is the callback function receiving a XMLHttpRequest object instead of a JSON object?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.