Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

URL Validity

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Luke Davis - 18 Sep 2007 21:43 GMT
Is there an easy method that takes a URL string and checks if it is valid?

Luke
Robbe Morris - [MVP] C# - 18 Sep 2007 21:51 GMT
What would you consider "invalid"?

Signature

Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials/aspnet/270e9432-d236-47e7-b1af-5cd3abe27a75
/net-propertygrid-control.aspx


> Is there an easy method that takes a URL string and checks if it is valid?
>
> Luke
Luke Davis - 18 Sep 2007 22:57 GMT
Invalid as in a 404 error or if it's an image it will come back with a red
"x".    There be nothing at the domain.   So if I passed http://google.com/ 
it would come back true, but if I passed http://asfsaf3985r2934.com it will
come back false.

> What would you consider "invalid"?
>
>> Is there an easy method that takes a URL string and checks if it is
>> valid?
>>
>> Luke
Robbe Morris - [MVP] C# - 18 Sep 2007 23:05 GMT
HttpWebRequest and HttpWebResponse

There are tons of samples for these two classes.

Signature

Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials/aspnet/270e9432-d236-47e7-b1af-5cd3abe27a75
/net-propertygrid-control.aspx


> Invalid as in a 404 error or if it's an image it will come back with a red
> "x".    There be nothing at the domain.   So if I passed
[quoted text clipped - 7 lines]
>>>
>>> Luke
Donn Felker - 19 Sep 2007 00:07 GMT
I have a post on how to work with HttpWebRequest here:
http://blog.donnfelker.com/2007/09/13/AutomatedFormPostingWithNETASPNETsCURL.aspx
Cowboy (Gregory A. Beamer) - 18 Sep 2007 21:55 GMT
You can Regex the string, but something like

http://www.thisisafakesite.com/default.aspx

would be seen as valid, as it is correctly formed. You would have to
actually issue a request to the server and check the return code to
determine if it was a real site.

Signature

Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************

| Think outside the box!

*************************************************
> Is there an easy method that takes a URL string and checks if it is valid?
>
> Luke
Jesse Houwing - 19 Sep 2007 23:40 GMT
Hello Cowboy (Gregory A. Beamer),

> You can Regex the string, but something like
>
[quoted text clipped - 12 lines]
>>
>> Luke

You could always pass it to the URI class and see what happens. My guess
is that it will choke on incorrectly formatted URI's.

--
Jesse Houwing
jesse.houwing at sogeti.n

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.