Salve a tutti ho creato una webform con il seguente codice :
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://connect.cr*****.com/v1/authenticate");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
string json = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}";
streamWriter.Write(json);
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
dynamic response = JsonConvert.DeserializeObject(result.ToString());
token = response.token;
txResponse.Text = token;
button1.Hide();
button2.Show();
this.txragsoc.Show();
this.labragsoc.Show();
this.txpartitaiva.Show();
this.labpartitaiva.Show();
System.Windows.Forms.MessageBox.Show("TOKEN OK !!");
}
}
catch (WebException ex)
{
using (WebResponse response = ex.Response)
{
HttpWebResponse httpResponse2 = (HttpWebResponse)response;
txResponse.Text = httpResponse2.StatusCode.ToString();
using (Stream data = response.GetResponseStream())
using (var reader = new StreamReader(data))
{
// text is the response body
string text = reader.ReadToEnd();
System.Windows.Forms.MessageBox.Show("ERROR :" + ex.ToString());
}
}
}
quando vado a metterla sulla mia webapp mi da questo errore :
InnerException = Impossibile leggere dati dalla connessione del trasporto: Connessione in corso interrotta forzatamente dall'host remoto
qualcuno ha qualche idea grazie