PDA

View Full Version : ASP - help needed



puzo
November 2nd, 2002, 07:36
Hi,
I would like to input this code on my index.asp page:


If Request.ServerVariables("REMOTE_ADDR") = "xxx.xxx.xxx.xxx" 'spammer IP Then
Response.Redirect "http://www.disney.com"
End If

Where exactly do i put it? iv'e tried putting it after the <HTML> tags but its a no go because it just shows this text, and doesnt preform the action.
Does any1 know how to make it work?

Thanks,

Mike

Joshwang
November 2nd, 2002, 07:46
you have to add <% and %> like this

<%
If Request.ServerVariables("REMOTE_ADDR") = "xxx.xxx.xxx.xxx" 'spammer IP Then
Response.Redirect "http://www.disney.com"
End If
%>

puzo
November 2nd, 2002, 07:54
I get a "500 Internal Server error" (http://puzo.org/test.asp)
here's my HTML code: (correct me if im wrong)



<html>
<br><h2><center>Test Page</center></h2>
<%
If Request.ServerVariables("REMOTE_ADDR") = "212.199.*.*" 'spammer IP Then
Response.Redirect "http://www.disney.com"
End If
%>
</html>


PuZo

noeska
November 2nd, 2002, 13:48
Response.Redirect should be placeed before any output is send to the browser. The best place also is the first line of you code before the html tag. This way you are sure nothing is send to the browser. Also i would remove the comment tag as it might obscure the then part of your code.

puzo
November 2nd, 2002, 13:51
could you edit the code and paste it here for me?

PuZo

acidmist_mike
November 2nd, 2002, 21:28
<%
If Request.ServerVariables("REMOTE_ADDR") = "212.199.*.*" 'spammer IP Then
Response.Redirect "http://www.disney.com"
End If
%>
<html>
<other crap>

puzo
November 3rd, 2002, 05:20
thank you very much, ill try it

PuZo

puzo
November 3rd, 2002, 05:26
no, it doesnt work, i still get a 500 Internal Server Error, any advice?

Mike

acidmist_mike
November 3rd, 2002, 06:46
Originally posted by puzo
no, it doesnt work, i still get a 500 Internal Server Error, any advice?

Mike

Does any other asp scripts work? It could be a problem with the asp engine itself.

puzo
November 3rd, 2002, 07:16
sure, i have a Snitz forum and an ASP counter.
could it be because of a script error in the script itself?

noeska
November 3rd, 2002, 15:43
<%
If Request.ServerVariables("REMOTE_ADDR") = "212.199.177.179" Then
Response.Redirect "http://www.disney.com"
End If
%>
<html>
here comes your own (html) code.

acidmist_mike
November 3rd, 2002, 19:13
The following codes have been tested to work on my server:

<%
If Request.ServerVariables("REMOTE_ADDR") = "*.*.*.*" Then
Response.Redirect "http://www.disney.com"
End If
%>
<html>
<other crap>


http://www.acidmist.com/pub/redirect.asp


Note that you can't use wildcards for ip address in asp. You could, alternatively, just compare the first two sets of the ip.

puzo
November 4th, 2002, 05:25
its ok i figured it out, thanks anyway.

Mike