Problems in retrieving HttpResponse content
-
Hello , I am posting on the server side application using a "Response.Write(str)" statement, where "str" contains some XML code . On the client side I am getting the response using a HttpWebResponse . When I get the HttpWebResponse content , I find , apart from the correct XML code that I posted on server side, soem kind of strange trailer which resembles an Html page, but is absolutely random (I mean , this "html page" changes from session to session...) . What is the reason of this strange result ? I am posting some relevant code below to help explain : Server side : Resp = ....some XML code .... Response.Write(Resp); Client side : HttpWebRequest WR = (HttpWebRequest)(WebRequest.Create(url)); HttpWebResponse Resp = (HttpWebResponse)WR.GetResponse(); Stream RS = Resp.GetResponseStream(); StreamReader SR = new StreamReader(RS); string mess = SR.ReadToEnd(); Resp.Close(); textBoxResponse.Text = mess; Thank you in advance Leo
-
Hello , I am posting on the server side application using a "Response.Write(str)" statement, where "str" contains some XML code . On the client side I am getting the response using a HttpWebResponse . When I get the HttpWebResponse content , I find , apart from the correct XML code that I posted on server side, soem kind of strange trailer which resembles an Html page, but is absolutely random (I mean , this "html page" changes from session to session...) . What is the reason of this strange result ? I am posting some relevant code below to help explain : Server side : Resp = ....some XML code .... Response.Write(Resp); Client side : HttpWebRequest WR = (HttpWebRequest)(WebRequest.Create(url)); HttpWebResponse Resp = (HttpWebResponse)WR.GetResponse(); Stream RS = Resp.GetResponseStream(); StreamReader SR = new StreamReader(RS); string mess = SR.ReadToEnd(); Resp.Close(); textBoxResponse.Text = mess; Thank you in advance Leo
I'm guessing that you're calling
Response.Write
from the code-behind of an ASP.NET page? In which case, the content of the page will still be output to the response after the text you've passed to theResponse.Write
method. You'll need to callResponse.End
after your last call toResponse.Write
to prevent this.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I'm guessing that you're calling
Response.Write
from the code-behind of an ASP.NET page? In which case, the content of the page will still be output to the response after the text you've passed to theResponse.Write
method. You'll need to callResponse.End
after your last call toResponse.Write
to prevent this.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer