Hi. I'm trying to login to a website using HTTP POST method. I've inspected and altered the POST data while logging in to the website and I came to the conclusion that only the two "username" and "password" fields are required to be passed as POST data to the login page, I removed all other headers namely user-agent, Referer etc and still I was able to login to the website(using Firefox). However when I try to do this in my solution I keep getting "The remote server returned an error: (417) Expectation Failed."
I should also note that I've tried doing it both with HTTPWebResponse/HttpWebRequest and WebClient, They have both resulted in the same thing; Here's a sample of the code I'm using: (I'm getting the Exception right when I try to get a response from the page)
WebClient client = new WebClient();
NameValueCollection postData = new NameValueCollection();
postData.Add("username", "MyUserName");
postData.Add("password", "MyPassword");
byte[] response = client.UploadValues("http://www.example.com/login.php",postData);
Console.WriteLine(new System.Text.ASCIIEncoding().GetString(response));//This is where I get the Exception.
Console.ReadKey();
I'm sorry if this issue has been covered before But after a day of Googling I still couldn't find a reasonable answer explaining why it works with my browser and not with my application. If you need extra info feel free to ask here. Thanks for your time and sharing your knowledge in advance. ~Phidelity
EDIT - I fixed my posted code. It was correct in my solution but I typed it wrong here. Sorry for the confusion.