I'm using WebClient.DownloadString(url) to download a web page, when a url a 404 web page it stops and doesn't work anymore. I want to skip these pages when I got this fault.
if the url is 404 page, it doesn't start to download. so i can't parse the undownloaded data...
You can put your code in a
Try...Catch
block and catch a WebException. If you want more control on how to handle specific errors, you can use the WebException'sStatus
property which returns a WebExceptionStatus enumeration.You will have to catch the Exception and test for a 404: