Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to redirect to a PDF file 1

Status
Not open for further replies.

christheprogrammer

Programmer
Jul 10, 2000
258
CA
Good day everyone -

I am trying to display a PDF document on a web page by using Response.Redirect("somefile.pdf") and I have the required plugin.

Now, when the redirection happens, the browser displays a completely white screen with nothing on it (it appears the PDF didn't load). The weird thing is, if I press the browser's back button and then forward button, the pdf loads up perfectly in the browser!

I have tried everything I know about, but this problem won't go away. I have definitely seen pages where a PDF is loaded in the browser, and I never had to press Back then Forward! Why is this happening in my application?

Any sort of input is welcomed - Thanks in advance Chris says: "It's time for a beer."
 
here:

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.WriteFile(strName);
Response.Flush();
Response.Close();

where strName contains path + filename

hth
 
Well, that did it. Thanks and here's a star for you. BTW - where can I find a list of the contentTypes? I have had no luck trying to find them. Cheers & congrats on being a dad soon.... :)

Chris says: "It's time for a beer."
 
it mainly follows the HTTP specifications of your web browser. Therefore you must look for that support for the type of browser you are using.

and thanks =) hehehe due date is November 12th =)
 
this is what you get from the VS.NET help:

ContentType

The ContentType property specifies the HTTP content type for the response. If no ContentType is specified, the default is text/HTML.

Syntax

Response.ContentType [= ContentType ]

Parameters

ContentType
A string describing the content type. This string is usually formatted type/subtype where type is the general content category and subtype is the specific content type. For a full list of supported content types, see your Web browser documentation or the current HTTP specification.
Example

The following example sets the content type to Channel Definition Format (CDF).

<% Response.ContentType = &quot;application/x-cdf&quot; %>

The following examples set the ContentType property to other common values.

<% Response.ContentType = &quot;text/HTML&quot; %>
<% Response.ContentType = &quot;image/GIF&quot; %>
<% Response.ContentType = &quot;image/JPEG&quot; %>
<% Response.ContentType = &quot;text/plain&quot; %>
<% Response.ContentType = &quot;image/JPEG&quot; %>

Applies To

Response Object
 
Thanks again - I have been wondering where to look for this stuff for ages. I have needed to learn this forever but got tied up with other stuff (as usual).

Chris says: &quot;It's time for a beer.&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top