yan

yan

  • NA
  • 1
  • 0

How do i post a web page from code, without losing session?

Jul 16 2009 8:46 AM
Hello, I've been trying for some time now, to post some information to a SSL web page, when the first step is getting the page, and the second step is filling the form and posting to the same page. I've tried to do this using HttpWebRequest and HttpWebResponse, Passing the CookieContainer from one to another in order to maintain session consistency. Unfortunately, the page re-renderes at the second step, as if i just loaded it for the first time (the response does not redirect me to the result page, but to the form page itself. actually, i get the same response for both my requests.) This is probably because the second request is not included in the same session as the initial request. When i used a sniffer to check the difference between the code performance and a regular browser performance, i noticed some cookies (with the word 'session' in its names) were missing when i post from code. my only guess is that the web page is using Javascript to add the session cookie. How can i simulate a web browser good enough, so this page would recognize me the second time i request it? Is there any workaround to use the Windows.Forms.WebBrowser ActiveX control? (I am writing an asp.net service) Note that the POST string (key=value&key=value...) is computed perfectly by my code. Any answers would be very appreciated. Thanks ahead, YAT.

Answers (1)