Get full url from relative url

Discussion in 'ASP .Net Web Controls' started by David Thielen, May 25, 2006.

  1. Hi;

    In the code behind of a control, how can I convert "~/report.aspx" to
    "http://www.domain.com/portal/report.aspx"?

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com
     
    David Thielen, May 25, 2006
    #1
    1. Advertising

  2. Hi David,

    Thank you for post!

    For the "/portal/report.aspx" part, we can use "Page.ResolveUrl" to get it:

    Page.ResolveUrl("~/report.aspx")

    Normally this part is enough for page navigation. If you need to get the
    "http://server" part, you can use "Request.Url" to construct it:

    Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port

    Hope this helps. If there's anything unclear, please feel free to post here.

    Regards,
    Walter Wang
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Walter Wang [MSFT], May 26, 2006
    #2
    1. Advertising

  3. That does it. I'm surprised there is not a single call to give the full url
    (we use it when in a page they cause an email to be sent with a url to the
    site).

    --
    thanks - dave
    david_at_windward_dot_net
    http://www.windwardreports.com



    "Walter Wang [MSFT]" wrote:

    > Hi David,
    >
    > Thank you for post!
    >
    > For the "/portal/report.aspx" part, we can use "Page.ResolveUrl" to get it:
    >
    > Page.ResolveUrl("~/report.aspx")
    >
    > Normally this part is enough for page navigation. If you need to get the
    > "http://server" part, you can use "Request.Url" to construct it:
    >
    > Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port
    >
    > Hope this helps. If there's anything unclear, please feel free to post here.
    >
    > Regards,
    > Walter Wang
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
     
    David Thielen, May 26, 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. wl
    Replies:
    1
    Views:
    4,463
  2. Samuel R. Neff
    Replies:
    2
    Views:
    610
    bradley
    Jun 10, 2005
  3. EYEBUZZ

    Relative or Full Path

    EYEBUZZ, Feb 3, 2004, in forum: HTML
    Replies:
    2
    Views:
    541
    Leif K-Brooks
    Feb 3, 2004
  4. Replies:
    1
    Views:
    190
    Ken Bloom
    May 28, 2007
  5. slugger3113

    getting full URL from relative links

    slugger3113, Apr 19, 2010, in forum: Perl Misc
    Replies:
    4
    Views:
    238
    slugger3113
    Apr 19, 2010
Loading...

Share This Page