Determing web-site root

  • Thread starter Thread starter Mantorok
  • Start date Start date
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


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
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.
 
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. ;)
 
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

Back
Top