Absolute url from relative path

Discussion in 'ASP .Net' started by Andreas Zita, Dec 31, 2005.

  1. Andreas Zita

    Andreas Zita Guest

    How do I get the absolute url for a file from c#-code?

    I have the path "~/file.aspx" and I want
    "http://www.mydomain.xyz/myapp/file.aspx"

    Basically I want to get the complete app-path url including the domain from
    the current app, but I have only found ways of getting the physical path and
    the virtual path ???

    /Andreas
     
    Andreas Zita, Dec 31, 2005
    #1
    1. Advertisements

  2. Andreas Zita

    Sosh Guest

    Andreas,

    This might help: http://west-wind.com/weblog/posts/269.aspx


    "Andreas Zita" <> wrote in message
    news:...
    > How do I get the absolute url for a file from c#-code?
    >
    > I have the path "~/file.aspx" and I want
    > "http://www.mydomain.xyz/myapp/file.aspx"
    >
    > Basically I want to get the complete app-path url including the domain
    > from the current app, but I have only found ways of getting the physical
    > path and the virtual path ???
    >
    > /Andreas
    >
     
    Sosh, Dec 31, 2005
    #2
    1. Advertisements

  3. Andreas Zita

    Patrick Smacchia

    Joined:
    Oct 18, 2007
    Messages:
    1
    Likes Received:
    0
    Patrick Smacchia, Oct 18, 2007
    #3
  4. Andreas Zita

    bharathmr

    Joined:
    Mar 21, 2008
    Messages:
    3
    Likes Received:
    0
    try httpcontext

    try HttpContext.Current.Request.Url
    this will give you the request url and you could append this to the
    required file accordingly.

    Let me know, if this helps.
    Thank you

    Bharath
     
    bharathmr, Apr 29, 2008
    #4
    1. Advertisements

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,659
  2. Matt
    Replies:
    3
    Views:
    20,720
    Sudsy
    Jul 8, 2004
  3. =?Utf-8?B?UGF1bCBCb25mYW50aQ==?=

    Response.Redirect() converts relative URL to absolute URL

    =?Utf-8?B?UGF1bCBCb25mYW50aQ==?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    6,743
    bruce barker \(sqlwork.com\)
    Apr 25, 2006
  4. Thomas Guettler
    Replies:
    3
    Views:
    1,000
    Andrei
    Oct 27, 2003
  5. Rudi Ahlers
    Replies:
    11
    Views:
    1,176
    Aaron Bertrand [MVP]
    Apr 11, 2004
  6. Nigel Wilkinson
    Replies:
    2
    Views:
    611
    Nigel Wilkinson
    Jul 25, 2005
  7. James Byrne
    Replies:
    3
    Views:
    881
    James Byrne
    Sep 14, 2010
  8. John Nagle

    Relative URL to an absolute URL?

    John Nagle, Feb 26, 2008, in forum: Javascript
    Replies:
    3
    Views:
    425
    John Nagle
    Feb 26, 2008
Loading...