Relative URL's to absolute URL's function ?

Discussion in 'ASP .Net' started by wl, Jul 14, 2004.

  1. wl

    wl Guest

    Hi,

    I would like to create a new URL based on the URLReferer. Well it's
    difficult to explain (which is probably I can't find anything on Google):

    eg 1
    URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value =
    "asecondfile.aspx"
    --> http://www.mysite.com/somedir/asecondfile.aspx

    eg2:
    URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value =
    "../asecondfile.aspx"
    --> http://www.mysite.com/asecondfile.aspx

    eg2:
    URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value =
    "http://www.anothersite.com/asecondfile.aspx"
    --> http://www.anothersite.com/asecondfile.aspx

    So this basically would need to translated relative URL's to absolute URL's.

    Is there any method in the framework that can do this for me, without having
    to write my own code ?

    Thanks,

    Wim
     
    wl, Jul 14, 2004
    #1
    1. Advertising

  2. wl

    wl Guest

    While describing my problem I found a good description and tried this in
    Google, and I found it.

    [C#]
    Uri baseUri = new Uri("http://www.contoso.com/");
    Uri myUri = new Uri(baseUri, "catalog/shownew.htm?date=today");

    Console.WriteLine(myUri.AbsolutePath);

    Thanks,

    Wim


    "wl" <> wrote in message
    news:...
    > Hi,
    >
    > I would like to create a new URL based on the URLReferer. Well it's
    > difficult to explain (which is probably I can't find anything on Google):
    >
    > eg 1
    > URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value

    =
    > "asecondfile.aspx"
    > --> http://www.mysite.com/somedir/asecondfile.aspx
    >
    > eg2:
    > URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value

    =
    > "../asecondfile.aspx"
    > --> http://www.mysite.com/asecondfile.aspx
    >
    > eg2:
    > URLReferer = http://www.mysite.com/somedir/afile.aspx and given URL value

    =
    > "http://www.anothersite.com/asecondfile.aspx"
    > --> http://www.anothersite.com/asecondfile.aspx
    >
    > So this basically would need to translated relative URL's to absolute

    URL's.
    >
    > Is there any method in the framework that can do this for me, without

    having
    > to write my own code ?
    >
    > Thanks,
    >
    > Wim
    >
    >
     
    wl, Jul 14, 2004
    #2
    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. Andreas Zita

    Absolute url from relative path

    Andreas Zita, Dec 31, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    29,682
    bharathmr
    Apr 29, 2008
  2. =?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,313
    bruce barker \(sqlwork.com\)
    Apr 25, 2006
  3. Thomas Guettler
    Replies:
    3
    Views:
    790
    Andrei
    Oct 27, 2003
  4. Rudi Ahlers
    Replies:
    11
    Views:
    863
    Aaron Bertrand [MVP]
    Apr 11, 2004
  5. John Nagle

    Relative URL to an absolute URL?

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

Share This Page