I’m trying to get the picture to load in the same PHP session in which the POST request will be sent.
But because i’m using button1_Click this is not possible.
And the outcome is to get the picture to load before the data is sent.
If you got any questions please ask.
i know i go wrong with the picture loading, but i dont know exactly where..
using visual c# 2010 express winforms
private void Form1_Load(object sender, EventArgs e)
{
pictureBox1.ImageLocation = "http://localhost/proj/guess-my-fav/1.jpg";
}
private void button1_Click(object sender, EventArgs e)
{
Uri uri = new Uri("http://localhost/proj/guess-my-fav/level14.php");
var answer = textBox1.Text;
string data = "guess=" + answer + "&level=14&time=opt";
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Post;
request.CookieContainer = new CookieContainer();
request.KeepAlive = true;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tmp = reader.ReadToEnd();
response.Close();
richTextBox1.AppendText(tmp); // log - delete this line
}
How can i put the rendering of image under the second request?
If you modify your code to match
This should make both requests to the server using the same session.
Hope this helps.