The connection was closed unexpectedly for System.Net.HttpWebRequest.GetRequestStream()

J

J0915

I created a web Asp.Net application (web forms) in c# with Sql Server Express for an online store integrated with PayPal. I used the code for pdt given at this site. Everything worked perfectly during development using sendbox and Visual Studio 2019, but on Windows Server 2016, after the payment on PayPal by redirecting to the page on the site in a protected area, the connection drops and generates an error on the line of code

StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII)

I can't understand what is wrong.

I added the following code:

- on the redirect page

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

- on the web.config

<binding openTimeout="00:10:00" closeTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00" />

Also I checked the SSL certificate, that is ok. I update the framework to the latest version.

On IIS 8 there's this error:

Event code: 3005 Event message: An unhandled exception
has occurred. Event sequence: 22 Event occurrence: 1 Event detail code:
0 Application information: Trust level: Full Process information: Process ID: 6472 Process name: w3wp.exe Account name: NT
AUTHORITY\SYSTEM Exception
information: Exception type: WebException Exception
message: The
underlying connection was closed: The connection was closed unexpectedly. at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) at System.Net.HttpWebRequest.GetRequestStream() at website.ProtectArea.shopping.Page_Load(Object sender, EventArgs e) in C:\xxxx\website\shopping.aspx.cs:line 44 at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint) Request information:
Request URL: https://website.com/ProtectArea/shopping + token info from PayPal
Request path: /ProtectArea//shopping
User host address: xx.xxxx.xxx.xx
User: xxxx@xxxxx.com Is authenticated: True Authentication
Type: ApplicationCookie
Thread account name: NT AUTHORITY\SYSTEM Thread
information: Thread ID: 16 Thread account name:
NT AUTHORITY\SYSTEM Is impersonating: False

Continue reading...
 
Back
Top Bottom