By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

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

P: n/a


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.

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David Cho" <pr********@yahoo.com> wrote in message
news:uR*************@TK2MSFTNGP12.phx.gbl...


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.

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #2

P: n/a


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

*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #3

P: n/a
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).
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"David Cho" <pr********@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...


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

*** Sent via Developersdex http://www.developersdex.com ***

Nov 17 '05 #4

P: n/a

Problem solved.

It was the incomplete installation of third party software. In this
case, covenanteyes (covenanteyes.com).
*** Sent via Developersdex http://www.developersdex.com ***
Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.