473,624 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8796
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********@hotm ail.com
http://www.nathansokalski.com/

<so******@yahoo .comwrote in message
news:83******** *************** ***********@a70 g2000hsh.google groups.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.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
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******** *************** ***********@a70 g2000hsh.google groups.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
2221
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 Cookbook. So please forgive me if this isn't the best approach - I'm open to suggestions I finally got my code to work that logs into another site and pulls the orderstatus page to my server.
5
11187
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 after having navigated to some page, it doesn't work. It just returns to the start page or says "timeout" etc. This means that I can't read these pages from PHP with $string = file_get_contents('http://some.url/blah/deep/link');
5
6406
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 number of web sites for certain domains, but I would like the majority of the code for this page to be on 1 central site so that if I need to do an update of this page I only need to update it on one site.
10
3330
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 doesn't realize it unless he looks at the opener page's source code. I'm wondering if there's a javascript solution for this? I've tried using the window.opener.location.replace with the href being my absolute URL, and triggered by an onUnload...
1
1283
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 I'm collecting, so I'd like to take advantage of using server-side controls, but validation is performed and a record or two are created in table, I need to post SOME of the data from the aspx to another site (Verisign) for credit card...
1
2673
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 service (www.collages.net) to host each photo session and I would like to put a login form on my web site to log into this other services web page. I just want to make it easier for the customer.
1
1354
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 should remain on the client's site. Or at least appear that they are remaining on the client's site. One thing that would be acceptable is to host the page on the client's site, but have it hit my site to get the data. I have looked into XMLHTTP...
5
6650
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: I have a JavaScript function that looks like this: function DoPostRedir() { document.MainFrm.method = "POST"; document.MainFrm.action = "http://XXX.YYY.com/Help/";
2
1726
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. How can I do this easily? Thanks
0
8242
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8177
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8681
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8629
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.