473,508 Members | 2,227 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XMLHttp from Server

I want to use XMLHTTP or something like it from my server code.

I'm trying to call a web page, and I want the results back into a string.

ideas? Thanks, Dave

Nov 19 '05 #1
4 2786
There is a sample that is application to both the .NET Compact Framework
and the .NET Framework.

Search for "bool Upload" in this article

http://www.eggheadcafe.com/articles/...encryption.asp

--
2004 and 2005 Microsoft MVP C#
Robbe Morris
http://www.robbemorris.com
http://www.masterado.net/home/listings.aspx

"Dave H" <Da***@noemail.nospam> wrote in message
news:Ia********************@comcast.com...
I want to use XMLHTTP or something like it from my server code.

I'm trying to call a web page, and I want the results back into a string.

ideas? Thanks, Dave

Nov 19 '05 #2
Hi Dave,

As for calling a web page and get the response stream text, where will you
make this call ? In your ASP.NET web application 's serverside code( .net
managed code) or in clientside script code?

If the call is made in asp.net serverside code( c# or vb.net), I think we'd
better use the HttpWebRequest class in the .net 's BCL which has more
powerful functions on http network processing such as making http get/post
request and get the response stream, here is a tech article discussing on
this:

#How To: Fetching Web Pages with HTTP
http://www.csharp-station.com/HowTo/HttpWebFetch.aspx

If you're making the call in clientside script, you can consider using
XMLHttp, here are the MSDN reference on using IXMLHTTPRequest ( XMLHttp is
one of the implementation of that COM interface):

#IXMLHTTPRequest
http://msdn.microsoft.com/library/en...tpRequest.asp?
frame=true

#Using Microsoft's XMLHTTP Object to Get Data From Other Web Pages
http://www.4guysfromrolla.com/webtech/110100-1.shtml

@@@Note: in clientside code, we use XMLHTTP, however, in serverside code
(such as classic asp page or other server app), we should use ServerXMLHTTP
instead:

#How To Submit Form Data by Using XMLHTTP or ServerXMLHTTP Object
http://support.microsoft.com/default...b;en-us;290591
BTW, All the MSXML component (COM based) are not supported to use in .net
managed code, we should always use the buildin .net fundamental class
library's components if possible.

#INFO: Use of MSXML is Not Supported in .NET Applications
http://support.microsoft.com/default...b;en-us;815112

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #3
I've done it from client side JS code, I wanted the same type from ASP
server side code.

Thanks to you both... Dave

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:vA**************@TK2MSFTNGXA01.phx.gbl...
Hi Dave,

As for calling a web page and get the response stream text, where will you
make this call ? In your ASP.NET web application 's serverside code( .net
managed code) or in clientside script code?

If the call is made in asp.net serverside code( c# or vb.net), I think we'd better use the HttpWebRequest class in the .net 's BCL which has more
powerful functions on http network processing such as making http get/post
request and get the response stream, here is a tech article discussing on
this:

#How To: Fetching Web Pages with HTTP
http://www.csharp-station.com/HowTo/HttpWebFetch.aspx

If you're making the call in clientside script, you can consider using
XMLHttp, here are the MSDN reference on using IXMLHTTPRequest ( XMLHttp is
one of the implementation of that COM interface):

#IXMLHTTPRequest
http://msdn.microsoft.com/library/en...tpRequest.asp? frame=true

#Using Microsoft's XMLHTTP Object to Get Data From Other Web Pages
http://www.4guysfromrolla.com/webtech/110100-1.shtml

@@@Note: in clientside code, we use XMLHTTP, however, in serverside code
(such as classic asp page or other server app), we should use ServerXMLHTTP instead:

#How To Submit Form Data by Using XMLHTTP or ServerXMLHTTP Object
http://support.microsoft.com/default...b;en-us;290591
BTW, All the MSXML component (COM based) are not supported to use in .net
managed code, we should always use the buildin .net fundamental class
library's components if possible.

#INFO: Use of MSXML is Not Supported in .NET Applications
http://support.microsoft.com/default...b;en-us;815112

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Nov 19 '05 #4
Thanks for your prompt response Dave,

So since you are wanting to do it at serverside, we have the following
means:

1. Using ServerXMLHTTP component in classic ASP page , we can just
vbscript or jscript in asp page.

#Using ServerXMLHTTP Directly
http://msdn.microsoft.com/library/en...mserverxmlhttp
_using_directly.asp?frame=true

2. Using HttpWebRequest class in asp.net web page, we can use C# or VB.NET.

http://msdn.microsoft.com/library/en...NetHttpWebRequ
estClassGetResponseTopic.asp?frame=true
For your convenience, I've pasted two test code snippet below. Hope helps.
ASP server code (JScript)
===========================
<%@ Language="JScript" %>

<%

var url = "http://www.asp.net";
var objSrvHTTP;
objSrvHTTP = Server.CreateObject ("Msxml2.ServerXMLHTTP.3.0");
objSrvHTTP.open ("GET",url, false);
objSrvHTTP.send ();

Response.Clear();
Response.ContentType = "text/html";
Response.Write (objSrvHTTP.responseText);
Response.End();

%>
============================
ASP.NET serverside code (C#)
============================
private void Page_Load(object sender, System.EventArgs e)
{
string url = "http://www.w3.org";

HttpWebRequest webreq = WebRequest.Create(url) as HttpWebRequest;

webreq.Method = "GET";

//specify proxy if necessary
//webreq.Proxy = new WebProxy("xxxx",80);

HttpWebResponse webrep = webreq.GetResponse() as HttpWebResponse;

StreamReader sr = new StreamReader(webrep.GetResponseStream());

string responseHtml = sr.ReadToEnd();

sr.Close();
webrep.Close();
Response.ClearContent();
Response.Write(responseHtml);
Response.End();
}
============================
Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #5

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

Similar topics

3
3079
by: Mark | last post by:
Hi all i was just wondering if you help. I have to send a cgi request to a company using xmlhttp request. They reply back with a line of info but when you view the internet explorer source code...
9
5552
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
12
13759
by: Botan Guner | last post by:
Hi all, Here is the problem, i'm using Microsoft.XMLHTTP for ie and XMLHttpRequest for mozilla, on my local server which is win2000 server i've no problem with that but when i uploaded the file...
6
10441
by: Vanessa | last post by:
I have a question regarding async mode for calling Microsoft.XMLHTTP object. Microsoft.XMLHTTP hangs the IE once in a while suddenly, but it will work again after half an hour or so without doing...
1
6556
by: Raúl Martín | last post by:
I´ve a function in asp that run correctly but If I tried to change it forasp.net in asp: xmlHTTP = CreateObject("Microsoft.XMLHTTP") And I thought to use this sentence for asp.net but the...
1
14470
by: cwl | last post by:
I want to get the content of a webpage containing plain text and write the content to a text file. My code looks like this: Set xmlhttp = CreateObject("Microsoft.XMLHTTP")...
1
7370
by: KoosJaspers | last post by:
I have a remarkable problem. Opening a file using xmlhttp works perfectly. The responseText output is read, since it can be assigned to an alert() message, as follows : alert(xmlhttp.resposeText)...
14
9977
by: FMDeveloper | last post by:
Currently transitioning from a shared host to a dedicated server. The same code that works on the old server is not working on the dedicated server. It is a simple AJAX request like: <code>...
14
14117
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
I've been searching everywhere online to find an alternative method besides using Microsoft.XMLHTTP (as it freezes the server up alot!!) but with no luck at all. I am using server side ASP, and...
2
19157
by: Dave | last post by:
I am running the following code and I get an error: Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0") xmlHttp.Open "Get", URLToRSS, false xmlHttp.Send RSSXML = xmlHttp.ResponseText The...
0
7336
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,...
0
7401
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...
1
7063
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4720
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...
0
3211
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...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
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 ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.