I am having one windows application which calls an asp.net webpage.
i want to return a file stream object form asp.net page & want to access that filestream object in windows application.
can any body tell me how to do that.
i am calling the webpage like this.
Dim url as string
url = "Http:\\localhost\Sample\WebForm1.aspx"
Dim
WebRequest As HttpWebRequest = HttpWebRequest.Create(url)when i try to get response stream like this
Dim stream As Stream = response.GetResponseStream()
it returns nothing
how can i get filestream object returned by asp.net page in windows app.
Thanks

How to pass objects across applications
Giriraj Singh
Hi Mike,
I have changed my code a bit in this aspx page i am sending you that, this returns some xml code that i want to receive in my windows app but i am getting full response that an aspx page generates, can you tell me how can i get only xml code that aspx page generates.
here is the code of aspx file.
Protected
iXmlDocument As New XmlDocument Protected iRoot As XmlElement Protected iSoapEnvelope As XmlDocument = New XmlDocument Protected iSoapHeader As XmlElement Protected iSoapBody As XmlElement Protected iAction As String Private iURL As String Private iCompressThreshold As Integer Private iSoapSchema As String = "http://schemas.xmlsoap.org/soap/envelope/" Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadretStream()
End Sub Public Function retStream() As XmlDocumentiSoapEnvelope.AppendChild(iSoapEnvelope.CreateXmlDeclaration("1.0", "UTF-8", "yes"))
'Write SOAP EnvelopeiSoapEnvelope.AppendChild(iSoapEnvelope.CreateElement("soapenv", "Envelope", iSoapSchema))
iSoapHeader = iSoapEnvelope.CreateElement("soapenv", "Header", iSoapSchema)
iSoapEnvelope.FirstChild.NextSibling.AppendChild(iSoapHeader)
AddHeaderElement("action", "workloadlist")
AddHeaderElement("sessionid", "MySession")
CreateHeaderElements(iSoapHeader)
iSoapBody = iSoapEnvelope.CreateElement("soapenv", "Body", iSoapSchema)
iSoapEnvelope.FirstChild.NextSibling.AppendChild(iSoapBody)
iXmlDocument.AppendChild(iXmlDocument.CreateElement("processX"))
iRoot = iSoapEnvelope.CreateElement("process")
If Not iXmlDocument Is Nothing TheniRoot.InnerXml = iXmlDocument.OuterXml
End IfiSoapBody.AppendChild(iRoot)
CreateBodyElements(iRoot)
Return iSoapEnvelopewhen i try to get this iSoapEnvelop in my windows code through these lines
Dim response As HttpWebResponse = CType(iRequest.GetResponse(), HttpWebResponse) Dim stream As Stream = response.GetResponseStream() Dim sr As StreamReadersr =
New StreamReader(stream, Encoding.UTF8)MsgBox(sr.ReadToEnd())
this sr gives me compelete response that an aspx page generates whereas i just want the code in iSoapEnvelop.
please help me in achieving that.
Thanks for your support
ZsoltKiraly
I think you are misundestanding how the data generated in your retStream() function is sent over the wire. Just because you return an object from that function doesn't mean that it was written to the network as the response to the HttpWebRequest. You need to serialize the data and write it to the HttpResponse (not HttpWebResponse). In other words, in your ASPX code, you need write the data using "Response.Write()".
Need the scoop
Rich M Turner
Can you provide a bit more detail Are you seeing an exception
You read the stream and there is no data If this is the case, you can use netmon or System.Net tracing to determine if data is being sent accross the wire: http://blogs.msdn.com/dgorti
webguynj
Ryan Yuen
Hi Mike,
when i try to iterate through the stream then i get this exception
Dim response As HttpWebResponse = CType(iRequest.GetResponse(), HttpWebResponse) Dim stream As Stream = response.GetResponseStream()An unhandled exception of type 'System.NotSupportedException' occurred in system.dll
Additional information: This stream does not support seek operations.
Thanks