473,669 Members | 2,421 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 2797
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******** ************@co mcast.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):

#IXMLHTTPReques t
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.m icrosoft.com> wrote in message
news:vA******** ******@TK2MSFTN GXA01.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):

#IXMLHTTPReques t
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
estClassGetResp onseTopic.asp?f rame=true
For your convenience, I've pasted two test code snippet below. Hope helps.
ASP server code (JScript)
=============== ============
<%@ Language="JScri pt" %>

<%

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

Response.Clear( );
Response.Conten tType = "text/html";
Response.Write (objSrvHTTP.res ponseText);
Response.End();

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

HttpWebRequest webreq = WebRequest.Crea te(url) as HttpWebRequest;

webreq.Method = "GET";

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

HttpWebResponse webrep = webreq.GetRespo nse() as HttpWebResponse ;

StreamReader sr = new StreamReader(we brep.GetRespons eStream());

string responseHtml = sr.ReadToEnd();

sr.Close();
webrep.Close();
Response.ClearC ontent();
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
3089
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 you see the XML format. I was just wonder if anyone could help me save the xml format to a xml file. I woul like to show you my code but there is to much confidential information about the company.
9
5556
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, using the same HTML/JS it always returns no data (xmlhttp.responseText is null). When I try to get headers using Mozilla or display the http status code I get some obscure exception in the javascript console that I've given up on searching for an...
12
13788
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 to the web server of our company which is redhat 9 i still have no problem with mozilla but the ie gives an error like this, System error: -1072896658
6
10449
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 anything. I have searched through the Internet and seems like the reason it hangs the browser it's because XMLHTTP limits you to two concurrent HTTP connections to each remote host; so if more than 2 concurrent connections strike the script...
1
6571
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 server don´t response right. xmlHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP")
1
14521
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") xmlhttp.setRequestHeader "Content-type","text/txt" xmlhttp.Open "get", "http://www.mysite.com/default.asp", False xmlhttp.Send text = xmlhttp.responseText dim fs, fname
1
7396
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) However, xmlhttp.responseTest can NOT be assigned to a normal string variable, UNLESS the file is already present in the temporary internet folder. This problem only occurs in the remote webserver context, not on my local system. It seems that a...
14
10006
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> function createXMLHttpRequest() { if (window.ActiveXObject) { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } else if (window.XMLHttpRequest) {
14
14166
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 some said to use Microsoft.ServerXMLHTTP instead. However I have tried that as well and it still freezes up the whole thing (i.e. the site just keeps loading forever). I tried to do a "on error resume next" clause to catch the error but still...
2
19208
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 error is: msxml3.dll error '800c0005'
0
8465
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
8383
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
8809
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...
1
6210
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
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
4206
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
4386
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2032
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1788
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.