473,499 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

URL Validity

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

Luke
Sep 18 '07 #1
6 1443
What would you consider "invalid"?

--
Robbe Morris [Microsoft MVP - Visual C#]
..NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials...d-control.aspx


"Luke Davis" <lu**@gorealco.comwrote in message
news:eO****************@TK2MSFTNGP03.phx.gbl...
Is there an easy method that takes a URL string and checks if it is valid?

Luke
Sep 18 '07 #2
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.

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

*************************************************
| Think outside the box!
|
*************************************************
"Luke Davis" <lu**@gorealco.comwrote in message
news:eO****************@TK2MSFTNGP03.phx.gbl...
Is there an easy method that takes a URL string and checks if it is valid?

Luke

Sep 18 '07 #3
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#" <in**@eggheadcafe.comwrote in message
news:uP****************@TK2MSFTNGP05.phx.gbl...
What would you consider "invalid"?

--
Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials...d-control.aspx


"Luke Davis" <lu**@gorealco.comwrote in message
news:eO****************@TK2MSFTNGP03.phx.gbl...
>Is there an easy method that takes a URL string and checks if it is
valid?

Luke

Sep 18 '07 #4
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/tutorials...d-control.aspx


"Luke Davis" <lu**@gorealco.comwrote in message
news:eK****************@TK2MSFTNGP04.phx.gbl...
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#" <in**@eggheadcafe.comwrote in message
news:uP****************@TK2MSFTNGP05.phx.gbl...
>What would you consider "invalid"?

--
Robbe Morris [Microsoft MVP - Visual C#]
.NET PropertyGrid Control - ListBox, ComboBox, and Custom Classes
http://www.eggheadcafe.com/tutorials...d-control.aspx


"Luke Davis" <lu**@gorealco.comwrote in message
news:eO****************@TK2MSFTNGP03.phx.gbl...
>>Is there an easy method that takes a URL string and checks if it is
valid?

Luke

Sep 18 '07 #5
I have a post on how to work with HttpWebRequest here:
http://blog.donnfelker.com/2007/09/1...PNETsCURL.aspx

Sep 18 '07 #6
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!
|
*************************************************
"Luke Davis" <lu**@gorealco.comwrote in message
news:eO****************@TK2MSFTNGP03.phx.gbl...
>Is there an easy method that takes a URL string and checks if it is
valid?

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.nl
Sep 19 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5261
by: vishal | last post by:
how can i verify the email address entered by client??? is there any readily available function for that in php or mysql????? else suggest me some links for verifying email address enetered...
3
3692
by: Rex_chaos | last post by:
Hi there, I have a question about using expression template. We know that the final calculation in expression template will end up with a series of element-by-element operations. The concept can...
12
2476
by: Troy | last post by:
My ISP provides me with 2 servers: one for normal web hosting (non-PHP) and a CGI server (with PHP). I create my website using fusion 7 and upload this in its entirity to the web hosting server....
7
1454
by: Michael Sgier | last post by:
Hi folks class X { private: CTexture *modelTex; // texture data } CTexture* X::Load()
16
3351
by: jacob navia | last post by:
Valid pointers have two states. Either empty (NULL), or filled with an address that must be at a valid address. Valid addresses are: 1) The current global context. The first byte of the data...
33
4505
by: a | last post by:
Hi, I have a pointer that points to an unknown heap memory block, is it possible to check the pointer + 3 is valid or not? If it is impossible, how can I do the check? Thanks
9
1637
by: Andy Dingley | last post by:
Here's a chunk of a longer piece of punditry I'm working on, re: the choices between doctypes for authoring and the State of the Union for validity. I've got a bucketload of nasty code and a bunch...
2
1912
by: shuisheng | last post by:
Dear All, Assume I have a class for a cuboid domain. The domain is defined by the cuboid's lower corner, such as (0, 0, 0), and upper corner, such as (1, 1, 1). The upper corner should be always...
9
2949
by: xhe | last post by:
Hi, I need to program to check the validity of IP address through PHP Initially I used this one: $url="http://www.ntc.gov.au/ViewPage.aspx? page=A02400304500100020"; $fp=fopen($url,"r");...
4
3276
by: istillshine | last post by:
I have a function foo, shown below. Is it a good idea to test each argument against my assumption? I think it is safer. However, I notice that people usually don't test the validity of...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7386
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5468
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.