Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Fully qualified root URL

0 views
Skip to first unread message

JJ

unread,
Oct 31, 2006, 12:02:53 PM10/31/06
to
I am embarrassed to ask this as I'm sure it must be easy to do, but I've
looked everywhere.

I just want to get the root url of my web site:
i.e. http://www.mywebsite.com/

I am writing code that produces a HTML newletter that is sent out to
subscribers. The images therefore need fully qualifed links (not relative
ones). As I'd like to use this code on other sites, I want to find the root
url programmatically.

As I am developing in visual studio 2005 hosting environment at the moment,
so I guess the caculation would come up with something like
'http://locahost:1234/www.mywebsite.com' . On the 'live site it needs to
return 'http://www.mywebsite.com/' . Can 'ApplicationPath' be used here?

I'm confused - sorry. Any help very appreciated.

JJ


JJ

unread,
Oct 31, 2006, 12:16:13 PM10/31/06
to
Some seem to be using this method:
string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority +
Request.ApplicationPath.TrimEnd('/') + '/';

But I have read that using 'Request.' variables doesn't always work?

??

"JJ" <a...@xyz.com> wrote in message
news:ez%235o5Q$GHA....@TK2MSFTNGP03.phx.gbl...

Juan T. Llibre

unread,
Oct 31, 2006, 12:18:42 PM10/31/06
to
Dim appname as string = Request.Url.Host
Dim FQN as string = "The full URL to the application root is : " & "http://" & appname &
Request.ApplicationPath & "/"

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================


"JJ" <a...@xyz.com> wrote in message news:ez%235o5Q$GHA....@TK2MSFTNGP03.phx.gbl...

0 new messages