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 127111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:25:29+00:00 2026-05-11T05:25:29+00:00

I am trying to respond back to a client with a PDF stored in

  • 0

I am trying to respond back to a client with a PDF stored in a MSSQL varbinary(MAX) field. The response works on my localhost and a test server over http connection, but does not work on the production server over https connection. I am using just a simple BinaryWrite (code below).

    byte[] displayFile = DatabaseFiles.getPdfById(id);      Response.ContentType = 'application/pdf';     Response.BinaryWrite(displayFile); 

Nothing fancy here. Just grab the binary data, set the content type, and write back to client. Is there anything special that needs to be done in order to respond back over https in this way?

Edit: By doesn’t work, I mean that I get a blank document in the browser. Acrobat does not load in browser.

Edit: I just noticed that this problem is only occurring in IE 7. The PDF loads correctly in Firefox 3. Our client uses IE 7 exclusively (better than IE 6 which I persuaded them upgrade from…lol).

Edit: Tried to add the header ‘content-disposition’ to make the file act as an attachment. Browser failed to loaded under SSL with the IE error ‘Internet Explorer cannot download displayFile.aspx from ProductionServer.net.’ (Code Below)

    byte[] displayFile = DatabaseFiles.getPdfById(id);     Response.Clear();     Response.AddHeader('content-disposition', String.Format('attachment;filename={0}', fileName));     Response.ContentType = 'application/pdf';     Response.BinaryWrite(displayFile); 

Edit: If the file is viewed over http on the Production Server, the browser displays the code for the PDF like it was being viewed through NotePad. (e.g. %PDF-1.4 %âãÏÓ 6 0 obj <> endobj xref 6 33 …etc)

  • 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-11T05:25:29+00:00Added an answer on May 11, 2026 at 5:25 am

    I just managed to get around this by replacing

    Response.Clear(); 

    with

    Response.ClearContent(); Response.ClearHeaders(); 

    so the whole thing looks like:

    byte[] downloadBytes = doc.GetData(); Response.ClearContent(); Response.ClearHeaders();  Response.Buffer = true; Response.ContentType = 'application/pdf'; Response.AddHeader('Content-Length', downloadBytes.Length.ToString()); Response.AddHeader('Content-Disposition', 'attachment; filename=myFile.pdf'); Response.BinaryWrite(downloadBytes); Response.Flush(); Response.End(); 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make my site respond correctly to the back button. I've saved
I am trying to have a simple java server respond to an XmlHttpRequest, but
I am just trying to test a simple ajax call on my server using
I'm trying to use strtotime() to respond to a button click to advance -1
I'm trying to write a WCF service to respond to ajax requests, but I'm
How to respond to HTTP GET with c#/.net and XML What I am trying
I'm trying to write the server side of my android app that uses C2DM.
I have fought enough with this: I am trying to write a TCP client
I am trying to develop a client application that calls a RESTful web service.
I am trying to implement a minimal chat server in java over regular TCP

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.