cattivik66
Newcomer
- Joined
- Apr 4, 2004
- Messages
- 12
Hi all!
I'd like to make a program that check if a server is alive, and if not, post on the support forum of the hoster the problem.
I use System.Net.WebClient to check if the server works.
On MSDN I've found how to make a post, but I've 2 problems.
The first problem is that, to post on the support forum login (with cookies) is required. Second minor problem is that with one post I've to pass many parameters (username, password, etc to make the login, title and message to post).
Some1 have some suggestions?
Thx in advance
code to make a post:
I'd like to make a program that check if a server is alive, and if not, post on the support forum of the hoster the problem.
I use System.Net.WebClient to check if the server works.
On MSDN I've found how to make a post, but I've 2 problems.
The first problem is that, to post on the support forum login (with cookies) is required. Second minor problem is that with one post I've to pass many parameters (username, password, etc to make the login, title and message to post).
Some1 have some suggestions?
Thx in advance
code to make a post:
Visual Basic:
Dim uriString As String
Console.Write(ControlChars.Cr + "Please enter the URI to post data to{for example, http://www.contoso.com} : ")
uriString = Console.ReadLine()
' Create a new WebClient instance.
Dim myWebClient As New WebClient()
Console.WriteLine(ControlChars.Cr + "Please enter the data to be posted to the URI {0}:", uriString)
Dim postData As String = Console.ReadLine()
myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
' Apply ASCII Encoding to obtain the string as a byte array.
Dim byteArray As Byte() = Encoding.ASCII.GetBytes(postData)
Console.WriteLine("Uploading to {0} ...", uriString)
' Upload the input string using the HTTP 1.0 POST method.
Dim responseArray As Byte() = myWebClient.UploadData(uriString, "POST", byteArray)
' Decode and display the response.
Console.WriteLine(ControlChars.Cr + "Response received was :{0}", Encoding.ASCII.GetString(responseArray))