473,386 Members | 1,810 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.

HttpWebRequest fails

Hi,

I tried to send a HttpWebRequest, but it doesn't work, although it's so
simple.
Here is the Code:

HttpWebRequest InetReq =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com/");

HttpWebResponse myResponse;
try
{
myResponse = (HttpWebResponse)InetReq.GetResponse();
}
catch (Exception ex)
{
...
}

In the catch routine I get a MessageBox showing exception "Unable to connect
to the remote server" and inner exception "Connection could not be
established because the host refused the connection".
What's wrong here?

Thanks!
Feb 25 '06 #1
3 1860
I have tested your code and it works fine. No exception occured.

Feb 25 '06 #2
Markus Eder <Ma********@discussions.microsoft.com> wrote:
I tried to send a HttpWebRequest, but it doesn't work, although it's so
simple.
Here is the Code:

HttpWebRequest InetReq =
(HttpWebRequest)WebRequest.Create("http://www.contoso.com/");

HttpWebResponse myResponse;
try
{
myResponse = (HttpWebResponse)InetReq.GetResponse();
}
catch (Exception ex)
{
...
}

In the catch routine I get a MessageBox showing exception "Unable to connect
to the remote server" and inner exception "Connection could not be
established because the host refused the connection".
What's wrong here?


Are you able to make a connection with a browser directly from the same
box? Does your code do anything in terms of proxies which could be the
cause of the problem?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 25 '06 #3

The resolution of this problem is more then just stupid:
I forgot to turn ba firewall back on after a test. So WITHOUT the firewall
the connection failed. Turning it on made everything work fine :))
Feb 25 '06 #4

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

Similar topics

10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
4
by: Steven Pu | last post by:
Hi, Specifically, the website I am trying to access is, https://gmail.google.com/ I've read elsewhere that Google only uses SSL2, while .NET uses SSL3 and is not backward compatible. Is...
9
by: Matt Sollars | last post by:
I've exhausted all other avenues with this problem. Any help would be greatly appreciated. I am performing a simple POST via a HttpWebRequest object to an SSL URL (https://). I have attempted...
11
by: Keith Patrick | last post by:
Could someone explain to me the relationship between these two classes? I am ripping my hair out trying to divert an HttpRequest to a new location via an HttpWebRequest, but I cannot get my...
2
by: Maris Janis Vasilevskis | last post by:
Hi, Is it possible to force HttpWebRequest to do exactly (not approximately) the same as MSXML2.ServerXMLHTTP does? More details. I port JScript to JScript.NET I have a server (ASP invoking...
2
by: hharry | last post by:
hello all, trying to consume a simple web service using httpwebrequest instead of generating a proxy class. code for simple web service: Imports System.Web.Services ...
5
by: mr.newsgroupguy | last post by:
I am working in C# .NET 1.1. My app has a button on its main form that checks to see if it has access to a file on our server, just an XML file. On our server we are running W2K IIS with a...
1
by: mfreeman | last post by:
I have a VB.NET 2005 Windows application that worked fine when I ran it a month ago, and now it is throwing an exception ("The remote server returned an error: (500) Internal Server Error.") and I...
2
by: =?Utf-8?B?TGVuc3Rlcg==?= | last post by:
A C# (.NET 2) application which uses the System.Net.HttpWebRequest object to request a resource over HTTPS is failing following the installation of a new proxy server on our internal network with...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.