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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Redirects

Status
Not open for further replies.

crabgrass

Technical User
Aug 29, 2007
111
0
0
US
I find the following to be unreliable. Sometimes it works and sometimes it doesn't.
<code>
response.write("<meta http-equiv=refresh ")
response.write("content=0;url=http:contactsusers.asp>")
</code>
The same is true of
<code>
response.redirect("newpage.asp")
</code>
Is there something wrong with my construct or is there a better way?
 
There's nothing wrong with your ASP code. You didn't state what you mean by "Sometimes it works and sometimes it doesn't.", so it's kinda difficult to help you solve any problems.

Lee
 
Code:
response.write("<meta http-equiv=refresh ")
response.write("content=0;url=http:[red]//[/red]contactsusers.asp>")

Does it not need the two slashes? Other than pointing out typos, it's tough to tell what could be causing this without more info, as trollacious suggests
 
Thanks to both of you.

When I say it doesn't work, I mean the code just runs past it as if it wasn't there. Putting in the 2 slashes doesn't help.
 
How about a copy and paste of your real code?

Also, read how to use the code tags before posting your code.

Lee
 
Here's my actual code in this particular instance. Sorry about the misuse of the code flag. Differences in websites. :)
Code:
if lcDeleteFlag = "True" then
   sql= "EXEC 'delete from users where user_id = " & lcUser & "'" 
   oConn.Execute(sql)
   response.write("<meta http-equiv=refresh ")
   response.write("content=0;url=http://contactsusers.asp>")
   response.redirect("contactsusers.asp")	 
end If

The response.redirect in this case works. The 2 lines above it do not.
 
From what I could find, it looks like some quotes are missing:
Code:
if lcDeleteFlag = "True" then
   sql= "EXEC 'delete from users where user_id = " & lcUser & "'" 
   oConn.Execute(sql)
   response.write("<meta http-equiv=""refresh"" ")
   response.write("content=""0;url=http://[red]www.mydomain.com/[/red]contactsusers.asp"">")
   response.redirect("contactsusers.asp")     
end If
 
The response.redirect is what's executed because the HTML is never flushed to the client's browser.

What value is lcDeleteFlag showing? Is it actually a string value, or a boolean value? You're testing it as a string value in your code.

Lee
 
Its a string value placed into a hidden text via a button on the previous page.

Can you provide a dummies explanation of what you mean by
"the HTML is never flushed to the client's browser" and how I should deal with it?

Thanks
 
In short, what you've written in response.write never makes it to the client because your response.redirect takes it elsewhere. So, try commenting out the response.redirect and adding a response.flush --
Code:
if lcDeleteFlag = "True" then
   sql= "EXEC 'delete from users where user_id = " & lcUser & "'"
   oConn.Execute(sql)
   response.write("<meta http-equiv=""refresh"" ")
   response.write("content=""0;url=http://www.mydomain.com/contactsusers.asp"">")
   response.buffer = TRUE
   response.flush
   'response.redirect("contactsusers.asp")     
end If
 
The first question to answer, though, is what value lcDeleteFlag has in it. Try this inserted before the code you gave us here:
Code:
Response.Write lcDeleteFlag & "<br>"

If you flush the HTML to the client computer, you shouldn't use Response.Redirect. There's no point in doing the Response.Write, though, since all you want to do is redirect the page.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top