• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 425
  • Last Modified:

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

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
FalconUK
Asked:
FalconUK
  • 5
  • 3
1 Solution
 
fritz_the_blankCommented:
Once you stream, the redirect will never be called.

FtB
0
 
fritz_the_blankCommented:
One way around this is to spawn an extra window for the stream and then to redirect the original window.

FtB
0
 
FalconUKAuthor Commented:
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
fritz_the_blankCommented:
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
 
FalconUKAuthor Commented:
Cheers mate, did the trick nicely!
0
 
fritz_the_blankCommented:
Glad to have helped.

Any reason for the grade of B, then?

FtB
0
 
FalconUKAuthor Commented:
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
 
fritz_the_blankCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now