HttpWebRequest Session Length Problem

E

Edwardraoul

I need to send multiple WebRequests in the same session. The problem is I send the first request, which is a login request, receive the reply that the login is successful, then attempt to send another request, but receive a message back that I am not logged in. All of the requests are XML documents as well as the replies. Here is the code I have so far, which doesn't work..
string proxy = null;
XmlDocument LoginXml = login; //login xml documen
XmlDocument query = new XmlDocument(); //next transactio
query.Load("test.xml")
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://url";)
if(proxy != null) req.Proxy = new WebProxy(proxy,true)
req.ContentType = "text/xml";//;charset=\"utf-8\""
req.Accept = "text/xml"
req.Method = "POST"

Stream stm = req.GetRequestStream(); //sends first request to serve
LoginXml.Save(stm)
stm.Close()
WebResponse resp = req.GetResponse(); recieves response and stores in st
stm = resp.GetResponseStream()
Stream stm2 = req.GetRequestStream(); //attempt to send second reques
query.Save(stm2)
stm2.Close(); //this results in an error (stream not writable


StreamReader r = new StreamReader(stm)
string response = r.ReadToEnd(); //reads received stream into strin

r.Close(); //close streamreade
return response

I have tried many different methods to no avail, any advice would be greatly appreciated
Thank you
edward
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top