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

The connection was closed.

P: n/a
Hi, I have a web page that call another one with this code:

WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);

The web page called read the parameters, run the code and return 1 or
0.

The code that prepare the answer is the follow:

private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}

When I run the code happen an error:

Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.
How can I solve the problem?

Thanks in advice.

Jun 1 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Try commenting out Response.Close(); and see what happens.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************
<su*****@missmobile.netwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
Hi, I have a web page that call another one with this code:

WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);

The web page called read the parameters, run the code and return 1 or
0.

The code that prepare the answer is the follow:

private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}

When I run the code happen an error:

Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.

Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.
How can I solve the problem?

Thanks in advice.

Jun 1 '07 #2

P: n/a
On 2 Giu, 00:56, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
Try commenting out Response.Close(); and see what happens.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
Co-author: Microsoft Expression Web Bible (upcoming)

************************************************
Think outside the box!
************************************************<s upp...@missmobile.netwrote in message

news:11**********************@o5g2000hsb.googlegro ups.com...
Hi, I have a web page that call another one with this code:
WebClient SendSite = new WebClient();
SendSite.Headers.Add("Content-Type", "application/x-www-form-
urlencoded");
string StrReqSend = "Par1=aaa&Par2=2222";
byte[] Param = System.Text.Encoding.ASCII.GetBytes(StrReqSend);
byte[] Rps = SendSite.UploadData("http://localhost/nomeprogetto/
prova.aspx", "POST", Param);
The web page called read the parameters, run the code and return 1 or
0.
The code that prepare the answer is the follow:
private void WriteResult(string StrResult)
{
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "text/plain";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Write(StrResult);
Response.Flush();
Response.Close();
}
When I run the code happen an error:
Unable to read data from the transport connection: The connection was
closed.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.IO.IOException: Unable to read data from the
transport connection: The connection was closed.
How can I solve the problem?
Thanks in advice.- Nascondi testo tra virgolette -

- Mostra testo tra virgolette -
Hi, if I comment Response.Close(); works fine but i receive too HTML
code.

The page must contain only the value of "StrResult" because the same
page are request by a lot of VB6 application.

I can't upgrade all VB6 application....

Thanks in advice

Matteo

Jun 4 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.