I want to make a desktop application that enters a value in textbox and performs button actions for example design an application that enters value in google search box at google.com and performs action as when any one presses search button i wrote a code but it threw exception The remote server returned an error: (405) Method Not Allowed.
WebClient wc = new WebClient();
string uri = "http://google.com";
NameValueCollection nvc = new NameValueCollection();
nvc.Add("search", "afnan");
byte[] response = wc.UploadValues(uri, nvc);
textBox1.Text=Encoding.ASCII.GetString(response);
UploadValuesis trying to do aPOST(by default, at least; some other verbs are allowed, but they essentially still treat it as a body payload). It sounds like you just want aGETquery like http://www.google.com/search?q=afnan – so just url-encode"afnan". Note, however, that you should always observe the target site’s Terms and Conditions – in particular section 5:If you do this, expect to get black-listed.