G
Guest
Hi all,
I have a simple .aspx page running on net 2.0 that is trying to do a http
post to a remote server. Here is the code
Private Function ProcessRequests(ByVal strbody As String) As String
Dim returnstr As String
Dim URL As String = "http://www.dydomain.com/test.asp"
Dim h As HttpWebRequest = CType(WebRequest.Create(URL), HttpWebRequest)
h.ContentType = "text/xml"
h.Method = "POST"
h.ContentLength = Len(strbody)
h.KeepAlive = True
h.Referer = "me"
h.UserAgent = "me"
Dim s As Stream = h.GetRequestStream()
Dim sw As New StreamWriter(s)
sw.Write(strbody)
sw.Close()
Dim hr As HttpWebResponse = CType(h.GetResponse, HttpWebResponse)
Dim s2 As Stream = hr.GetResponseStream
Dim sr As New StreamReader(s2)
returnstr = sr.ReadToEnd
sr.Close()
h = Nothing
hr.Close()
hr = Nothing
funcend:
Return returnstr
End Function
I get an error on the following line:-
Server Error in '/' Application.
--------------------------------------------------------------------------------
A socket operation encountered a dead network
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.Net.Sockets.SocketException: A socket operation
encountered a dead network
Source Error:
Line 111: h.UserAgent = "me"
Line 112:
Line 113: Dim s As Stream = h.GetRequestStream()
Line 114: Dim sw As New StreamWriter(s)
Line 115: sw.Write(strbody)
Source File: D:\Website Files\AppOne v2.0\appone remoting\Default.aspx.vb
Line: 113
Stack Trace:
[SocketException (0x2742): A socket operation encountered a dead network]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress) +1002146
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream() +1504525
_Default.ProcessRequests(Int32 lenderID, String strbody) in D:\Website
Files\AppOne v2.0\appone remoting\Default.aspx.vb:113
_Default.CheckNADAProvider() in D:\Website Files\AppOne v2.0\appone
remoting\Default.aspx.vb:97
_Default.Page_Load(Object sender, EventArgs e) in D:\Website Files\AppOne
v2.0\appone remoting\Default.aspx.vb:15
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42
This same code works on a .net 1.1 box on the same network. So I know
outbound access is OK. Any ideas? The box with the problems is running
Server 2003 Enterprise SP1 w/ net 2.0 RTM.
TIA!
I have a simple .aspx page running on net 2.0 that is trying to do a http
post to a remote server. Here is the code
Private Function ProcessRequests(ByVal strbody As String) As String
Dim returnstr As String
Dim URL As String = "http://www.dydomain.com/test.asp"
Dim h As HttpWebRequest = CType(WebRequest.Create(URL), HttpWebRequest)
h.ContentType = "text/xml"
h.Method = "POST"
h.ContentLength = Len(strbody)
h.KeepAlive = True
h.Referer = "me"
h.UserAgent = "me"
Dim s As Stream = h.GetRequestStream()
Dim sw As New StreamWriter(s)
sw.Write(strbody)
sw.Close()
Dim hr As HttpWebResponse = CType(h.GetResponse, HttpWebResponse)
Dim s2 As Stream = hr.GetResponseStream
Dim sr As New StreamReader(s2)
returnstr = sr.ReadToEnd
sr.Close()
h = Nothing
hr.Close()
hr = Nothing
funcend:
Return returnstr
End Function
I get an error on the following line:-
Server Error in '/' Application.
--------------------------------------------------------------------------------
A socket operation encountered a dead network
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.Net.Sockets.SocketException: A socket operation
encountered a dead network
Source Error:
Line 111: h.UserAgent = "me"
Line 112:
Line 113: Dim s As Stream = h.GetRequestStream()
Line 114: Dim sw As New StreamWriter(s)
Line 115: sw.Write(strbody)
Source File: D:\Website Files\AppOne v2.0\appone remoting\Default.aspx.vb
Line: 113
Stack Trace:
[SocketException (0x2742): A socket operation encountered a dead network]
System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot,
SocketAddress socketAddress) +1002146
System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) +33
System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure,
Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState
state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +431
[WebException: Unable to connect to the remote server]
System.Net.HttpWebRequest.GetRequestStream() +1504525
_Default.ProcessRequests(Int32 lenderID, String strbody) in D:\Website
Files\AppOne v2.0\appone remoting\Default.aspx.vb:113
_Default.CheckNADAProvider() in D:\Website Files\AppOne v2.0\appone
remoting\Default.aspx.vb:97
_Default.Page_Load(Object sender, EventArgs e) in D:\Website Files\AppOne
v2.0\appone remoting\Default.aspx.vb:15
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42
This same code works on a .net 1.1 box on the same network. So I know
outbound access is OK. Any ideas? The box with the problems is running
Server 2003 Enterprise SP1 w/ net 2.0 RTM.
TIA!