Could you help me with this question, I have a windows form in VS2019, which I want to get the html generated after send the captcha and other parameter (2 parameters), my windows form contains devexpress controls, a picture edit where I load the captcha, textedit1 where I put the captcha, textedit2 where i put the second parameter (e.g. 06892898), simplebutton1 where I clic to load the captcha to the picture edit, the simplebutton2 to request the website with the 2 parameters, the problem is that when i passed the two parameter in the url, so I got an html with the message "The session has finished", How could I get the session or keep alive the webclient object in C#. Thanks in advance, This is my code:
private WebClient myClient = new WebClient();
public FrmData()
{
InitializeComponent();
}
private void btnCaptcha_Click(object sender, EventArgs e)
{
myClient.DownloadFile(new Uri("http://ww4.essalud.gob.pe:7777/acredita/captcha.jpg"), @"c:\temp\captcha.jpg");
pictureCaptcha.Image = Image.FromFile(@"c:\temp\captcha.jpg");
}
private void btnLoad_Click(object sender, EventArgs e)
{
string line = string.Empty;
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://ww4.essalud.gob.pe:7777/acredita/servlet/Ctrlwacre?captchafield_doc=" + txtedit1.Text + "&td=1&nd=" + txtedit2.Text);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream(), System.Text.Encoding.UTF8);
line = sr.ReadToEnd();
sr.Close();
resp.Close();
XtraMessageBox.Show("" + line);
}
catch (Exception ex)
{
XtraMessageBox.Show("" + ex.Message);
}
}