1
I have a C# class for Windows that works normally, but I’d like it to work on Windows Phone.
The idea is to use HTTP methods get
and post
from a web page that has CAPTCHA.
I will show the captcha to the user and I will 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;
}
}
But Visual Studio is accusing that httpWebRequest.GetResponseStream()
there is no.
What other way to do this or correct the current?
I will test as soon as I get home and put the result. Thank you
– user11968