How to determine if URL is relative or literal?

Discussion in 'ASP .Net' started by =?Utf-8?B?QmVuIEZpZGdl?=, Nov 30, 2004.

  1. Is there any Framework classes that allow you to provide a URL as a string,
    and determine whether it is a relative URL or literal URL?

    Once that's determined, I'd then like to remove the protocol and domain
    sections.

    Ie:

    Take http://www.mydomain.co.uk/admin/admin.aspx

    and return

    /admin/admin.aspx

    Kind regards

    Ben
    =?Utf-8?B?QmVuIEZpZGdl?=, Nov 30, 2004
    #1
    1. Advertising

  2. Thought that I might add to this that there are many ways of expressing
    relative and literal URL that a user could provide via a GUI:

    http://www.mydomain.co.uk/admin/admin.aspx
    www.mydomain.co.uk/admin/admin.aspx
    mydomain.co.uk/admin/admin.aspx
    /admin/admin.aspx
    admin/admin.aspx

    And if they want to provide a URL to a folder, but not a page:

    http://www.mydomain.co.uk/admin
    http://www.mydomain.co.uk/admin/
    www.mydomain.co.uk/admin
    mydomain.co.uk/admin
    admin
    /admin
    /admin/

    and so on...


    "Ben Fidge" wrote:

    > Is there any Framework classes that allow you to provide a URL as a string,
    > and determine whether it is a relative URL or literal URL?
    >
    > Once that's determined, I'd then like to remove the protocol and domain
    > sections.
    >
    > Ie:
    >
    > Take http://www.mydomain.co.uk/admin/admin.aspx
    >
    > and return
    >
    > /admin/admin.aspx
    >
    > Kind regards
    >
    > Ben
    =?Utf-8?B?QmVuIEZpZGdl?=, Nov 30, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?QmVuIEZpZGdl?=

    Karl Seguin Guest

    Best bet would probably be the Uri class
    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html
    /frlrfsystemuriclasstopic.asp)

    Create the path using the UriBuilder and use the various members of the Uri
    class to extract the required information.

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Ben Fidge" <> wrote in message
    news:...
    > Thought that I might add to this that there are many ways of expressing
    > relative and literal URL that a user could provide via a GUI:
    >
    > http://www.mydomain.co.uk/admin/admin.aspx
    > www.mydomain.co.uk/admin/admin.aspx
    > mydomain.co.uk/admin/admin.aspx
    > /admin/admin.aspx
    > admin/admin.aspx
    >
    > And if they want to provide a URL to a folder, but not a page:
    >
    > http://www.mydomain.co.uk/admin
    > http://www.mydomain.co.uk/admin/
    > www.mydomain.co.uk/admin
    > mydomain.co.uk/admin
    > admin
    > /admin
    > /admin/
    >
    > and so on...
    >
    >
    > "Ben Fidge" wrote:
    >
    > > Is there any Framework classes that allow you to provide a URL as a

    string,
    > > and determine whether it is a relative URL or literal URL?
    > >
    > > Once that's determined, I'd then like to remove the protocol and domain
    > > sections.
    > >
    > > Ie:
    > >
    > > Take http://www.mydomain.co.uk/admin/admin.aspx
    > >
    > > and return
    > >
    > > /admin/admin.aspx
    > >
    > > Kind regards
    > >
    > > Ben
    Karl Seguin, Nov 30, 2004
    #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,399
  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,039
    bruce barker \(sqlwork.com\)
    Apr 25, 2006
  3. David Thielen

    Get full url from relative url

    David Thielen, May 25, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    180
    David Thielen
    May 26, 2006
  4. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    363
    Anonieko Ramos
    Sep 27, 2004
  5. Rudi Ahlers
    Replies:
    11
    Views:
    787
    Aaron Bertrand [MVP]
    Apr 11, 2004
Loading...

Share This Page