Determing web-site root

J

Juan T. Llibre

You can construct it very easily with Request.Url.Host and Request.ApplicationPath.

Dim appname as string = Request.Url.Host
Dim fullappname as string = _
"The application root's full URL is : " & "http://" & appname & Request.ApplicationPath & "/"

See it working at : http://asp.net.do/test/apppath.aspx
 
R

Ray Booysen

Juan said:
You can construct it very easily with Request.Url.Host and Request.ApplicationPath.

Dim appname as string = Request.Url.Host
Dim fullappname as string = _
"The application root's full URL is : " & "http://" & appname & Request.ApplicationPath & "/"

See it working at : http://asp.net.do/test/apppath.aspx

Which fails if the site is using SSL.
 
J

Juan T. Llibre

re:
Which fails if the site is using SSL.

You can always do an if using either :

Request.ServerVariables("SERVER_PORT_SECURE")
or
System.Web.HttpRequest.IsSecureConnection

....can't you ?
 
R

Ray Booysen

Juan said:
re:

You can always do an if using either :

Request.ServerVariables("SERVER_PORT_SECURE")
or
System.Web.HttpRequest.IsSecureConnection

...can't you ?

Yup. ;)
 
M

Mantorok

Aha, that's where I was going wrong, I was trying to access it from the Url
alone, not the Request.

Thanks very much, that's great.
Kev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top