Fully qualified root URL

Discussion in 'ASP .Net' started by JJ, Oct 31, 2006.

  1. JJ

    JJ Guest

    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, Oct 31, 2006
    #1
    1. Advertising

  2. JJ

    JJ Guest

    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" <> wrote in message
    news:ez%235o5Q$...
    >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, Oct 31, 2006
    #2
    1. Advertising

  3. 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" <> wrote in message news:ez%235o5Q$...
    >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
    >
    Juan T. Llibre, Oct 31, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jacob Crossley
    Replies:
    0
    Views:
    391
    Jacob Crossley
    Apr 2, 2004
  2. Jacob Crossley
    Replies:
    0
    Views:
    333
    Jacob Crossley
    Apr 6, 2004
  3. Szabolcs Borsanyi

    Pointer to qualified poitner to qualified object

    Szabolcs Borsanyi, May 30, 2008, in forum: C Programming
    Replies:
    13
    Views:
    543
    Keith Thompson
    Jun 8, 2008
  4. jacob
    Replies:
    1
    Views:
    175
    Wes Henderson
    Apr 5, 2004
  5. Rudi Ahlers
    Replies:
    11
    Views:
    791
    Aaron Bertrand [MVP]
    Apr 11, 2004
Loading...

Share This Page