This topic is locked

Getting string from the current URL

6/27/2011 12:11:36 PM
ASPRunnerPro General questions
B
beachldy author

I'm wanting to read the URL (login pag) and get string values from it, particularly the IP such as 'localhost' from "http://localhost/...."; or 'Myweb.com' from "Http://MyWeb.com/login.asp";.
I want to do this on the login page before allowing them to login.
What's the best way to code getting the current URL?

------------------------------------------------------------------------------

I tried the code below and put the functions in a separate ASP page, but when calling it, got errors

"File could not be opened.

/cal/include/aspfunctions.asp, line 2852"

-------------------------------------------------------------------------------

function curPageURL()

dim s, protocol, port
if Request.ServerVariables("HTTPS") = "on" then

s = "s"

else

s = ""

end if
protocol = strleft(LCase(Request.ServerVariables("SERVER_PROTOCOL")), "/") & s
if Request.ServerVariables("SERVER_PORT") = "80" then

port = ""

else

port = ":" & Request.ServerVariables("SERVER_PORT")

end if
curPageURL = protocol & "://" & Request.ServerVariables("SERVERNAME") &

port & Request.ServerVariables("SCRIPT_NAME")

end function

'****

function strLeft(str1,str2)

strLeft = Left(str1,InStr(str1,str2)-1)

end function

Sergey Kornilov admin 6/29/2011

Probably you including this file the wrong way. What's the name of this file and how do you reference it?