I am automating the process of sign in and in the process of doing so, I will get different type of passwords which will include special characters.
My code is as below and I have tried to UrlEncode() the password, which didn't work. Please let me know if you find any issues in my code or which way i can find a work out. My passwords are "aab$#*#%232" and "@#:.;$%^&+-_h1&" :
string uriString = "http://" + IP + URI ;
string postData = "";
TraceLine("The uri string is " + uriString);
foreach (string key in values.AllKeys)
{
TraceLine(key + " " + values[key]);
postData += key + "=" + values[key] + "&";}}
if (postData.Length > 0) {
postData = postData.TrimEnd(postData[postData.Length - 1]);
}
TraceLine("The postData string is " + postData);
HttpWebRequest req =(HttpWebRequest)System.Net.WebRequest.Create(uriString);
req.ContentType = "application/x-www-form-urlencoded";
req.KeepAlive = false;
req.Method = "POST";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(postData);
req.ContentLength=bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();}