|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
ASP (Yuck) redirect page
I need help with a very simple ASP page.
I've never used ASP before and I'm sure the answers are in here, so I'm expecting to have rotten tomatoes thrown at me... Sorry, this is the only ASP page I ever hope to write... I have a page called intranet.asp All it needs to do is look at the remote_addr variable and depending on what it sees redirect to one of two places. The logic is as follows, and if this were PHP or Cold Fusion, I would be able to do it. IF (remote_addr == "192.168.xxx.xxx") { redirect to www.internal_address.com } else { redirect to www.external_address.com } The xxx's in 192.168.xxx.xxx mean that it can be any address inside the 192.168 tree. Any help would be greatly appreciated!
__________________
Forget Milk! Gotspy? www.gotspy.com |
|
#2
|
|||
|
|||
|
---BEGIN QUOTE---
Sorry, this is the only ASP page I ever hope to write ---END QUOTE--- Ok so I'll make it fast... If remote_addr = "192.168.xxx.xxx" Then Response.Redirect "www.internal_address.com" Else Response.Redirect "www.external_address.com" End If Try that! <edit> Did you want the example in Jscript? </edit> Hope this helps! Sincerely Vlince Last edited by Vlince : September 4th, 2003 at 12:10 PM. |
|
#3
|
||||
|
||||
|
Vince,
Thanks for the reply! It doesn't really matter to me what it's in, as long as it works. I tried your code and I ended up with a 404 error. I change the response.redirect to response.write("Yes") or NO depending on the results. In each case I got a NO response. I also tried to display the remote_addr but it comes up blank, so maybe I'm not grabbing the variable right?? The other question I had about this was the xxx.xxx, will ASP know those are variables? |
|
#4
|
|||
|
|||
|
how are you getting the remote_Address? You should be doing,
Request.servervariables(Remote_Addr). Quote:
Will not work as it is, you should be using a regular expression or just do mid(trim(Request.servervariables(Remote_Addr)),1,7) to get the first two octets of the IP.
__________________
If you ask a question you are a fool for a second. But if you dont ask, you are a fool for a life time. |
|
#5
|
|||
|
|||
|
Set DNS = CreateObject("TCPIP.DNS")
Host = DNS.gethostbyip(request.servervariables("remote_addr")) if blah then redirect else redirect end if maybe this well help |
|
#6
|
|||
|
|||
|
Well the remote_addr is obviously a variable right?
And you are saying that: Response.Write remote_addr Gives you a blank right? So of course if you do: If remote_addr = "192.168.xxx.xxx" Then Response.Write "YES" Else Response.Write "NO" End If You'll always get a *NO* answer since the remote_addr is blank! Now, find out *why* does the variable *remote_addr* gives you blank, I mean how do you retrieve it? Oh.......wait a minute LOL you mean If Request.ServerVariable("REMOTE_ADDR") = "192.168.xxx.xxx" Then Oh ok..sorry I thought it was a simple variable but I get it now ![]() Try that: Request.ServerVariable("REMOTE_ADDR") see if it helps! Sincerely Vlince |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > ASP (Yuck) redirect page |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|