WebClient.UploadData()

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
 
A

Alvin Bruney [MVP]

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

Al Cadalzo

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
 
A

Alvin Bruney [MVP]

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
 

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