473,408 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

The connection was closed.

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
2 1641
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steven Blair | last post by:
Hi, I am writing an application using a 3 tier model (Client, Business Layer and DB) The DB layer creates a OdbcDataReader object back up to the Client where the data is read and displayed on...
13
by: Larry | last post by:
Hi I have asp.net programs. I used a very simple data transfer method by using URLs ˇ°First.aspxˇ± contents a line to send data to the ˇ°second.aspxˇ± page, for
18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
26
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On...
4
by: Sin Jeong-hun | last post by:
I don't get the message so it's hard to debug that, but some of my clients report that they get "The underlying connection was closed unexpectedly" exception. According to this site (http://...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.