WebException: The underlying connection was closed: Unable to connect to the remote server
-
Hello, I try to get a Page from a IIS with following code snippet:
Dim strBody As String = "" Dim url As String = ConfigurationSettings.AppSettings("Url") & "/XXX.aspx" Dim oUri As New Uri(url) Dim oReq As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(oUri) Dim sString As String = "" ' Define the request access method. oReq.Method = "GET" oReq.KeepAlive = True ' Issue the request. Dim oResp As System.Net.WebResponse ' Issue the request. oResp = oReq.GetResponse() ' Store the response. Dim sData As System.IO.Stream = oResp.GetResponseStream() ' Read the page content and display it on the console. Dim read(2047) As [Byte] Dim bytes As Integer = sData.Read(read, 0, read.Length) While bytes > 0 sString = System.Text.Encoding.ASCII.GetString(read, 0, bytes) strBody += sString read.Clear(read, 0, read.Length) bytes = sData.Read(read, 0, read.Length) End While oResp.Close()
Note: This code is inside an Aspx-Page and I want to get a Page from the same Webserver, where this Page is running. On my local machine it works fine, but on the productive system I get a WebException like this:[WebException: The underlying connection was closed: Unable to connect to the remote server.] System.Net.HttpWebRequest.CheckFinalStatus() +673 System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult) +140 System.Net.HttpWebRequest.GetResponse() +147
The Exception comes too, if I run my Page direct on the productive system. I can not found any differences in the IIS-config between the prod-sys and my machine. Both computers are run in the local intranet in the same domain. Many Thanks Stephan