URL Validity

L

Luke Davis

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.


Robbe Morris - [MVP] C# said:
What would you consider "invalid"?

--
Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorial...af-5cd3abe27a75/net-propertygrid-control.aspx




Luke Davis said:
Is there an easy method that takes a URL string and checks if it is
valid?



Luke
 
R

Robbe Morris - [MVP] C#

HttpWebRequest and HttpWebResponse

There are tons of samples for these two classes.

--
Robbe Morris [Microsoft MVP - Visual C#]
..NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorial...af-5cd3abe27a75/net-propertygrid-control.aspx




Luke Davis said:
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.


Robbe Morris - [MVP] C# said:
What would you consider "invalid"?

--
Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorial...af-5cd3abe27a75/net-propertygrid-control.aspx




Luke Davis said:
Is there an easy method that takes a URL string and checks if it is
valid?



Luke
 
J

Jesse Houwing

Hello Cowboy (Gregory A. Beamer),
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.

*************************************************
| Think outside the box!
|
*************************************************

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top