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

Need some help with IP addresses

Status
Not open for further replies.

manjulam

Programmer
Feb 27, 2002
103
US
Hi,
I have a web application running on aa.aa.aa.aa
and it is hosted by bb.bb.bb.bb. So i am accessing the website by the ip address,so it is bb.bb.bb.bb/webappname.
Now,i provide a hyperlink in two websites with ip cc.cc.cc.cc and dd.dd.dd.dd to bb.bb.bb.bb/webappname.
And in the asp application, i have to check which website tried to request this page, cc.cc.cc.cc or dd.dd.dd.dd. I tried with the REMOTE_SERVER server variable but it always gives me aa.aa.aa.aa
I have to customise the look of the page based on who requested it. Please help me out.

Manjula
 
try Request.ServerVaribles("HTTP_REFERER"). This will give you the full URL of the page that called your site.

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Is there a way of getting the ip address out
of the HTTP_Referer variable?
 
some basic String manipulation on the HTTP_REFERER variable should retrieve it for you.

eg) if HTTP_REFERER =
Code:
strReferer = Request.ServerVariables("HTTP_REFERER")

strReferer = Replace(strReferer,"[URL unfurl="true"]http://","")[/URL]

strReferer = Replace(strReferer,"[URL unfurl="true"]http://","")[/URL]

intSlashPos = InStr(strReferer,"/")
strReferer = Left(strReferer,intSlashPos-1)



Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Mmmm, little bit to late with my string manipulaton:
Code:
<% 
dim cURL
cURL = "[URL unfurl="true"]http://123.456.789.0/test.asp"[/URL]
' where is the // ?
n = Instr( cURL, "//" )
' where is the next / ?
m = Instr( n+2, cURL, "/")
' IP number is in between!
response.Write mid(cURL, n+2, m - 8)
%>


But i don't see why you need an IP-address. You can adjust the code above a little so it returns xyz...

ttmug.gif
 
ASP lookup DNS software:

And after testing my code i found it is not working for addresses without / after //.
Next try:
Code:
<% 
dim cURL
cURL = "[URL unfurl="true"]http://www.xyz.com"[/URL]
n = Instr( cURL, "//" ) + 2
m = Instr( n+2, cURL, "/")
if m  = 0 then
  m = len(cURL) - 7
else
  m =  m - n
end if 
response.Write mid(cURL, n, m)
%>

ttmug.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top