473,386 Members | 1,758 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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!
Oct 16 '08 #1
2 8787
Take a look at:

http://www.4guysfromrolla.com/webtech/070601-1.shtml

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
nj********@hotmail.com
http://www.nathansokalski.com/

<so******@yahoo.comwrote in message
news:83**********************************@a70g2000 hsh.googlegroups.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!

Oct 16 '08 #2
Here is how I would handle this:

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

You can then stream it into output

StreamReader reader = new StreamReader(response.GetResponseStream);
string responseString = reader.ReadToEnd();

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(objWebClient.DownloadData(strURL));

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

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
<so******@yahoo.comwrote in message
news:83**********************************@a70g2000 hsh.googlegroups.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!
Oct 16 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: SteveJ | last post by:
All, Can someone help me solve the next step. First of all let me say I'm new to php. I pieced the following code together from samples I found on the net and a book I bought called PHP...
5
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window...
5
by: Astra | last post by:
Hi All Could you please confirm whether it is possible to include an include file, which is on another site, but still on the same set of web servers. I want to upload a default paeg to a...
10
by: Thad | last post by:
Any javascript I could try on this? I've got a popup window on my site with the browser chrome removed. Another site's gone ahead and done a popup to my same .html page. The visitor to that site...
1
by: Scott Newberry | last post by:
I'm having trouble figuring out the best way to post to another site. I have an aspx that collects information from the user, including credit card info, etc. I need to perform validation on what...
1
by: Sam Carleton | last post by:
My new asp.net 2.0 web site just went live today! http://www.miltonstreet.com Being the typical tinker, I am already adding to it! This is my photography studio's web site. I use another...
1
by: J. Cairn | last post by:
I am developing an ASP page for clients. I will host the page on my server, but it must appear on the clients' websites. That means that the user should not be redirected to my site, but instead...
5
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I am trying to create ASPX code which will allow me to redirect a user to another site with POST data. I figure that the best way to do this is with JavaScript to the client. Here's what I'm doing:...
2
by: ian.qmulus | last post by:
I have a very basic web site when somebody reaches it I want the site to display a message saying "you will be forward to another site in 10 seconds". Then in 10 seconds forward to another site....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.