asp.net page read response from another site?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • soni2926@yahoo.com

    #1

    asp.net page read response from another site?

    Hi,
    I wanted to make a page where I can send a request to another page,
    and read it's response back, can someone point me to an example? it's
    just a basic page i need to hit, i can hit it directly with my
    browser, no user/pass, but i want to read whats returned into a
    webpage, it's going to come back as html, wasn't sure if there's a
    control to just display whats returned, otherwise i can parse it, but
    main thing was how to send a request to another page and catch the
    response back.

    Thanks!
  • Nathan Sokalski

    #2
    Re: asp.net page read response from another site?

    Take a look at:

    eSports News, Results, upcoming Matches & live Matches. Learn tricks and guides in the esports space. ✅ We cover CS:GO, Dota 2, LOL, Overwatch & PUBG. 


    The two key classes you will be using are WebClient and UTF8Encoding. Also,
    take note that even though the example on this page gets generated HTML, the
    same process can be used for pretty much any type of data (for example, you
    could generate another type of text file such as XML, or even non-text stuff
    such as images or anything else you can make a file return, I have a few
    examples of doing this if you need them). Good Luck!
    --
    Nathan Sokalski
    njsokalski@hotm ail.com
    有声小说网为广大读者提供热门小说在线免费阅读,本站收集的网络文学小说情节跌宕起伏,有声小说网是值得书友们收藏的小说在线阅读网。


    <soni2926@yahoo .comwrote in message
    news:8360c053-3524-471f-8353-776ac4e7c551@a7 0g2000hsh.googl egroups.com...
    Hi,
    I wanted to make a page where I can send a request to another page,
    and read it's response back, can someone point me to an example? it's
    just a basic page i need to hit, i can hit it directly with my
    browser, no user/pass, but i want to read whats returned into a
    webpage, it's going to come back as html, wasn't sure if there's a
    control to just display whats returned, otherwise i can parse it, but
    main thing was how to send a request to another page and catch the
    response back.
    >
    Thanks!

    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: asp.net page read response from another site?

      Here is how I would handle this:

      string url = http://www.somesite.com/somepage.html;
      HttpWebRequest request = HttpWebRequest. Create(url);
      HttpWebResponse response = request.GetResp onse();

      You can then stream it into output

      StreamReader reader = new StreamReader(re sponse.GetRespo nseStream);
      string responseString = reader.ReadToEn d();

      You can also process the stream as it comes across.
      string line;
      while(null != (line = reader.ReadLine ())
      {
      //Get rid of lines you do not want, etc.
      }

      I like this method, as it gives you a lot of control. I would have to look,
      as you might be able to do this, as well.

      //Per http://www.4guysfromrolla.com/webtech/070601-1.shtml
      StreamReader reader = new StreamReader(ob jWebClient.Down loadData(strURL ));

      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA

      Subscribe to my blog


      or just read it:


      *************** *************** **************
      | Think outside the box! |
      *************** *************** **************
      <soni2926@yahoo .comwrote in message
      news:8360c053-3524-471f-8353-776ac4e7c551@a7 0g2000hsh.googl egroups.com...
      Hi,
      I wanted to make a page where I can send a request to another page,
      and read it's response back, can someone point me to an example? it's
      just a basic page i need to hit, i can hit it directly with my
      browser, no user/pass, but i want to read whats returned into a
      webpage, it's going to come back as html, wasn't sure if there's a
      control to just display whats returned, otherwise i can parse it, but
      main thing was how to send a request to another page and catch the
      response back.
      >
      Thanks!

      Comment

      Working...