Torna al Thread
' sito è la pagina a cui connettersi
' message sono i parametri da aggiungere
' state è lo state che nell'html è il valore associato a "_VIEWSTATE"
Dim request As HttpWebRequest = CType(WebRequest.Create(sito), HttpWebRequest)
request.Timeout = 10000
'imposto le credenziali di base
request.Credentials = CredentialCache.DefaultCredentials
'oppure assegno username e password e dominio
request.Credentials = New System.Net.NetworkCredential("USERNAME", "PASSWORD", sito)
Dim content As String = "Test Request Dotnethell"
Dim encoding As New ASCIIEncoding()
Dim Buffer As Byte() = encoding.GetBytes(message)
'imposto il contenttype generico per la richiesta che in base al tipo di richiesta fatta si deve impostare il content type corretto(Es. text/xml, text/html ecc)
request.ContentType = "application/x-www-form-urlencoded"
'imposto la lunghezza dei dati passati nella richiesta.
request.ContentLength = content.Length
Dim Stream As IO.Stream = request.GetRequestStream()
'scrivo nello streamnew
Stream.Write(Buffer, 0, Buffer.Length)
Stream.Close()
Dim response As HttpWebResponse = CType(request.GetResponse, HttpWebResponse)
Return response