Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Problems in retrieving HttpResponse content

Problems in retrieving HttpResponse content

Scheduled Pinned Locked Moved C#
questionhtmlsysadminxmlhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tiwal
    wrote on last edited by
    #1

    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

    Richard DeemingR 1 Reply Last reply
    0
    • T tiwal

      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

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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 the Response.Write method. You'll need to call Response.End after your last call to Response.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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      T 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        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 the Response.Write method. You'll need to call Response.End after your last call to Response.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

        T Offline
        T Offline
        tiwal
        wrote on last edited by
        #3

        I followed your instructions and now it works correctly.... I think I need to study better the way a web application works .... Thank you very much. Leo

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups