Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Test connection with WebClient

Status
Not open for further replies.

EwS

Programmer
Dec 30, 2002
398
0
0
US
The code below is what I use for posting an xml file to the remote server. It works fine. However, there are times when I just want to test if the server is down without actually sending any file. How can I do that?

Code:
public void PostResponse(String fileName, String uploadUrl)
{
   ASCIIEncoding oEncoder = new ASCIIEncoding();
   byte[] bytArray = oEncoder.GetBytes(fileName);
   try
   {
      WebClient myWebClient = new WebClient();
      Byte[] responseArray = myWebClient.UploadData   (uploadUrl, "POST", bytArray);
   }
   catch (Exception ex)
   {
      throw ex;
   }
   return;        
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top