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. Advertising

  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. Advertising

  3. Andreas Zita

    Patrick Smacchia

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

    bharathmr

    Joined:
    Mar 21, 2008
    Messages:
    3
    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. 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,454
  2. Matt
    Replies:
    3
    Views:
    19,631
    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,238
    bruce barker \(sqlwork.com\)
    Apr 25, 2006
  4. Thomas Guettler
    Replies:
    3
    Views:
    774
    Andrei
    Oct 27, 2003
  5. Nigel Wilkinson
    Replies:
    2
    Views:
    401
    Nigel Wilkinson
    Jul 25, 2005
Loading...

Share This Page