previous unencountered "The underlying connection was closed" message with HttpWebRequest

D

David Cho

Hi, this is just plain strange. This is my code.

HttpWebRequest request = (HttpWebRequest)
WebRequest.Create("http://www.yahoo.com");

request.Method = "POST";
request.ContentType = "text/xml";
StreamWriter sw = new StreamWriter(request.GetRequestStream()); //error
occurs here

The error is
"The underlying connection was closed: Unable to connect to the remote
server"

I've never had this problem before. This may be a symtom of a deeper
problem I am having. I cannot connect to any remote SQL server. Please
help.
 
N

Nicholas Paldino [.NET/C# MVP]

David,

Are you doing this in ASP.NET code, or any kind of program on your
machine? If this is ASP.NET code, the code runs under the ASPNET local
account by default, which doesn't have persmissions to access the network.
To get around this, you will have to run under an identity which has the
appropriate rights.

If this is happening for any program on the machine, I would check
things such as network settings, hardware drivers, etc, etc.

Hope this helps.
 
D

David Cho

The exactly identical code runs fine as a console application. Already
tried granting admin rights to the ASPNET account with no success.
 
N

Nicholas Paldino [.NET/C# MVP]

David,

You should not grant administrative rights to the ASPNET account (for a
number of reasons). It would be better if you impersonate a network user
through the use of the <identity> tag in the web.config file for the
application.

Better yet, this page should be in its own directory with its own
web.config file, which would allow just that one page to be run as that user
(and all other code runs under the ASPNET account).
 
D

David Cho

Problem solved.

It was the incomplete installation of third party software. In this
case, covenanteyes (covenanteyes.com).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top