ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 4th, 2003, 11:48 AM
gotspy's Avatar
gotspy gotspy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Buffalo, NY
Posts: 156 gotspy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 59 m 53 sec
Reputation Power: 6
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

Reply With Quote
  #2  
Old September 4th, 2003, 11:57 AM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
---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.

Reply With Quote
  #3  
Old September 4th, 2003, 01:49 PM
gotspy's Avatar
gotspy gotspy is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Buffalo, NY
Posts: 156 gotspy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 59 m 53 sec
Reputation Power: 6
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?

Reply With Quote
  #4  
Old September 4th, 2003, 01:58 PM
aspman aspman is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Ashburn,VA
Posts: 105 aspman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 22 m 40 sec
Reputation Power: 6
how are you getting the remote_Address? You should be doing,

Request.servervariables(Remote_Addr).

Quote:
The other question I had about this was the xxx.xxx, will ASP know those are variables


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.

Reply With Quote
  #5  
Old September 4th, 2003, 02:03 PM
bsw bsw is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 1 bsw User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Set DNS = CreateObject("TCPIP.DNS")
Host = DNS.gethostbyip(request.servervariables("remote_addr"))

if blah then
redirect
else
redirect
end if

maybe this well help

Reply With Quote
  #6  
Old September 4th, 2003, 02:06 PM
Vlince Vlince is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Canada, Quebec, Montreal
Posts: 410 Vlince User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > ASP (Yuck) redirect page


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway