How to use Get Post in C#
-
i need few demos of get post methods that will logs into any website and retrieves data from there.
-
i need few demos of get post methods that will logs into any website and retrieves data from there.
Sonu J wrote:
i need few demos of get post methods that will logs into any website and retrieves data from there.
..and what's your question? You can find demo's both on this site and Google. I'd suggest using a
WebBrowser
component, since that would simplify cookie-handling.I are Troll :suss:
-
i need few demos of get post methods that will logs into any website and retrieves data from there.
-
i need few demos of get post methods that will logs into any website and retrieves data from there.
#region HttpPost protected string HttpPost(string url_, string contents_, bool useCredentials_, NetworkCredential creds_) { bool isSuccess = false; int noOfRetry = 0; string response = string.Empty; try { WriteToLog(string.Format("Starting HTTPPost Publishing message {0} \r\n {1}", url_, contents_)); while (!isSuccess && noOfRetry < m_noOfRetry) { WriteToLog("HTTPPost " + "Success Status :" + isSuccess.ToString() + " Retry Count: " + noOfRetry.ToString()); Uri url = new Uri(url_); HttpWebRequest _webRequest = (HttpWebRequest)WebRequest.Create(url); _webRequest.Timeout = 400000000; _webRequest.Method = "POST"; _webRequest.ContentType = "text/xml; charset=ISO-8859-1"; _webRequest.KeepAlive = true; _webRequest.Credentials = CredentialCache.DefaultNetworkCredentials; if (useCredentials_) { string password = string.Empty; string username = string.Empty; //if no credentails provided then use if (creds_ == null) { password = ConfigurationManager.AppSettings["password"] == null ? null : ConfigurationManager.AppSettings["password"].ToString(); username = ConfigurationManager.AppSettings["user"] == null ? null : ConfigurationManager.AppSettings["user"].ToString(); if (password == null || username == null) { WriteToLog(SMSConstants.INCOMPLETE_SMSGATEWAY_INFORMATION); throw new Exception(SMSConstants.INCOMPLETE_SMSGATEWAY_INFORMATION); } WriteToLog("Connecting using UserName :" + username); password = GetDecString(password); String userInfo = username + ":" + password; byte[] bt = new byte[userInfo.Length]; bt = System.Text.Encoding.UTF8.GetBytes(userInfo); string encodedData = Convert.ToBase64String(bt); String authInfo = "Basic " + encodedData; _webRequest.Headers.Set("Authorization", authInfo);