WebClient.UploadData()

  • Thread starter Thread starter Al Cadalzo
  • Start date Start date
A

Al Cadalzo

I'm using VS.Net v7.1.3052

I'm using WebClient to do a POST:
Here's a code snippet:


(C#)

Byte[] responseArray = null;
try
{
responseArray = _webClient.UploadData(_curURL, "POST", byteArray); <<
Exception occurs here.
_curPage = System.Text.Encoding.ASCII.GetString(responseArray);
}

In DEBUG mode with 'Break into the debugger' option turned on I get an IO
Exception:
'Cannot close stream until all bytes are written.'
Followed by a 'WebException':
The RemoteServer returned an error (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus()

Any ideas?

Thanks,
Al
 
Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.
 
Alvin,

No, I have not resolved this issue.
On one execution it will fail, then I will rerun it and it will succeed and
I will get the page returned.
I would say it fails about 70% of the time.
I have reposted under a new subject line 'IO Exception: Cannot close stream
until all bytes are written.'

Thanks,
Al

Alvin Bruney said:
Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Al Cadalzo said:
I'm using VS.Net v7.1.3052

I'm using WebClient to do a POST:
Here's a code snippet:


(C#)

Byte[] responseArray = null;
try
{
responseArray = _webClient.UploadData(_curURL, "POST", byteArray); <<
Exception occurs here.
_curPage = System.Text.Encoding.ASCII.GetString(responseArray);
}

In DEBUG mode with 'Break into the debugger' option turned on I get an IO
Exception:
'Cannot close stream until all bytes are written.'
Followed by a 'WebException':
The RemoteServer returned an error (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus()

Any ideas?

Thanks,
Al
 
usually this kind of error indicates a problem resolving the path or url.
make sure the path is available and you have the appropriate access
permissions. it helps to configure iis to return friendly http messages
instead of the 500 error code. you can do this by going to
Tools/InternetOptions/Advanced and clearing the check mark

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Al Cadalzo said:
Alvin,

No, I have not resolved this issue.
On one execution it will fail, then I will rerun it and it will succeed and
I will get the page returned.
I would say it fails about 70% of the time.
I have reposted under a new subject line 'IO Exception: Cannot close stream
until all bytes are written.'

Thanks,
Al

Alvin Bruney said:
Your post went unanswered. Have you resolved this issue? If you still need
help, please post the original question with your request.

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Al Cadalzo said:
I'm using VS.Net v7.1.3052

I'm using WebClient to do a POST:
Here's a code snippet:


(C#)

Byte[] responseArray = null;
try
{
responseArray = _webClient.UploadData(_curURL, "POST", byteArray); <<
Exception occurs here.
_curPage = System.Text.Encoding.ASCII.GetString(responseArray);
}

In DEBUG mode with 'Break into the debugger' option turned on I get an IO
Exception:
'Cannot close stream until all bytes are written.'
Followed by a 'WebException':
The RemoteServer returned an error (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus()

Any ideas?

Thanks,
Al
 
Back
Top