For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > November 2004 > How to determine if URL is relative or literal?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to determine if URL is relative or literal?
Ben Fidge

2004-11-30, 9:04 am

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
Ben Fidge

2004-11-30, 9:04 am

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

2004-11-30, 4:02 pm

Best bet would probably be the Uri class
(http://msdn.microsoft.com/library/d...n-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" <BenFidge@discussions.microsoft.com> wrote in message
news:2E896366-1A19-42AF-951C-F7CF1A2428C8@microsoft.com...[color=darkred]
> 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:
>
string,[color=darkred]


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com