I am trying to login programetically using the following code, Untill two days before it worked fine, but now suddenly i am getting a WebException "The remote server returned an error: (417) Expectation Failed - " How to resolve this problem.
I also tried the solution posted in Why do I receive this error: The remote server returned an error: (417) Expectation Failed
Can any one tell me how to resolve this.
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://sms.ultoo.com/login.php");
String Postdata = "LoginMobile=9999999999&LoginPassword=aaa";
webRequest.Timeout = 10 * 60 * 1000;
webRequest.Method = "POST";
webRequest.ContentType = ContentType;
webRequest.ContentLength = Postdata.Length;
// POST the data
using (StreamWriter requestWriter2 = new StreamWriter(webRequest.GetRequestStream()))
{
requestWriter2.Write(Postdata);
}
// This actually does the request and gets the response back
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
string ResponseData = string.Empty;
using (StreamReader responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream()))
{
// dumps the HTML from the response into a string variable
ResponseData = responseReader.ReadToEnd();
}
Statement causing Exception
HttpWebResponse resp = (HttpWebResponse)webRequest.GetResponse();
ContentType
? – L.B