I have a class in C # for Windows that works normally, but I would like it to work on Windows Phone.
The idea is to use the HTTP methods get
and post
of a web page that has CAPTCHA.
I will show the captcha to the user and I will pass as post the answer.
<input type=hidden id=viewstate name=viewstate value='";
String StrImagemCaptcha = "<img border='0' id='imgcaptcha' alt='Imagem com os caracteres anti rob";
String UrlImagemCaptcha = "";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(UrlBase + UrlGet);
httpWebRequest.CookieContainer = cookieContainer;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Method = "GET";
httpWebRequest.AllowAutoRedirect = false;
//httpWebRequest.Timeout = 20000;
try
{
StreamReader stHtml = new StreamReader(httpWebRequest.GetResponseStream(), Encoding.GetEncoding("ISO-8859-1"));
HtmlResponse = stHtml.ReadToEnd();
stHtml.Close();
viewState = HtmlResponse;
PosString = viewState.IndexOf(StrViewState);
if (PosString >= 0)
viewState = viewState.Substring(PosString + StrViewState.Length);
PosString = viewState.IndexOf("'>");
if (PosString >= 0)
viewState = viewState.Substring(0, PosString);
UrlImagemCaptcha = HtmlResponse;
PosString = UrlImagemCaptcha.IndexOf(StrImagemCaptcha);
if (PosString >= 0)
UrlImagemCaptcha = UrlImagemCaptcha.Substring(PosString + 8 + StrImagemCaptcha.Length);
PosString = UrlImagemCaptcha.IndexOf("'>");
if (PosString >= 0)
UrlImagemCaptcha = UrlImagemCaptcha.Substring(0, PosString);
UrlImagemCaptcha = UrlImagemCaptcha.Replace("amp;", "");
}
catch (Exception ex)
{
_erro = ex.Message;
}
try
{
if (UrlImagemCaptcha.Length > 0)
return UrlDominio + UrlImagemCaptcha;
//return new System.Drawing.Bitmap(new System.IO.MemoryStream(new System.Net.WebClient().DownloadData(UrlDominio + UrlImagemCaptcha)));
else
return null;
}
catch (Exception ex)
{
_erro = ex.Message;
return null;
}
}
However Visual Studio is accusing that httpWebRequest.GetResponseStream()
does not exist.
What other way to do this or fix the current one?