Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Why is my Response.Redirect not working after a Response.Flush

Posted on 2004-09-22
8
Medium Priority
?
395 Views
Last Modified: 2012-06-27
I've got a script that sends a pdf to the browser for download, and then should re-direct the user to my home page.

The pdf downloads correctly but the re-direct isnt working, what am I doing wrong?

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Option Explicit
Const adTypeBinary = 1
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")

objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile Server.MapPath("..\..\") & "\data\downloads\Profile.pdf"

Response.Buffer = True
Response.Clear
Response.AddHeader "Content-Disposition", "attachment; filename=Profile.pdf"
Response.AddHeader "Content-Length", objStream.Size
Response.Charset = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite objStream.Read
Response.Flush

objStream.Close
rsDocs.Close
Set objStream = Nothing

Response.Redirect("/home.asp")
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Download Test</title>
</head>

<body>
<p>Download Script</p>
</body>
</html>
0
Comment
Question by:FalconUK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12122604
Once you stream, the redirect will never be called.

FtB
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12122616
One way around this is to spawn an extra window for the stream and then to redirect the original window.

FtB
0
 

Author Comment

by:FalconUK
ID: 12122867
By spawn an extra window do you mean using a pop up window?
Would this be done using JavaScript in the html once the page has loaded?

How would I do that?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Accepted Solution

by:
fritz_the_blank earned 1000 total points
ID: 12122906
Provide a link for the streaming window like this:

<a href="streamingPage.asp" target="_blank">Streaming Page</a>


If you want to move your current page back to the home page with this link, then you could try:

<a href="streamingPage.asp" target="_blank" onClick="location.replace("home.asp")">Streaming Page</a>

FtB
0
 

Author Comment

by:FalconUK
ID: 12123142
Cheers mate, did the trick nicely!
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12123182
Glad to have helped.

Any reason for the grade of B, then?

FtB
0
 

Author Comment

by:FalconUK
ID: 12123680
Sorry, no offence, your answer was quite right!

I'm still quite new to all of this, is there any way I can change it?
0
 
LVL 46

Expert Comment

by:fritz_the_blank
ID: 12123698
I'll take care of it and thanks.

http://www.experts-exchange.com/Web/Web_Languages/ASP/help.jsp#hi73

Good luck with your project,

FtB
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

647 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