Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for success of specific Web page
Message
 
À
30/12/2004 20:55:21
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
00973462
Message ID:
00973487
Vues:
14
This message has been marked as the solution to the initial question of the thread.
Just use the WebClient class. It's a few lines of code to retrieve a URL.
public string function GetUrl(Url)
{
string MergedText = "";
System.Net.WebClient Http = new System.Net.WebClient();

try
{
     byte[] Result = Http.DownloadData(Url);
     MergedText = Encoding.Default.GetString(Result);
}
catch(Exception ex) 
{
     ErrorMessage =  ex.Message;
     return null;
}

return MergedText;
}
If you need more control or need to figure out more about how to work with the full HTTP components in .NET check out:

http://www.west-wind.com/presentations/dotnetWebRequest/dotnetWebRequest.htm

There are a number of things that you can't do with WebClient in terms of configuration. I think setting timeouts was one so you may have to use the full thing.

FWIW, it sounds like what you're doing is exactly what Web Monitor is doing, which is a multi-threaded URL checker that lets you look for specific content in your output and send warning messages etc. There's a full source version that lets you customize either the app itself or the monitoring API that can be plugged into other applications.

+++ Rick ---


>I have six URL addresses that I need to check from VB.NET if the response returned is ok. Most of the examples I have found on the NET are dealing with pinging an IP address. I need to pull the result from a URL and interpret it. The logic should include a timeout parameter that after a few seconds, I'll decide if it is a failure or not. I need VB.NET code without any third party software to accomplish that. What would be the best route to consider?
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform