Are there any .Net experts in the audience?
I have a webserver running on a ND+1. It works great. I'm sending back a small bit of XML for testing. When I load up the webpage in IE or chrome it looks perfect. However, when I try to read this XML from a ASP.Net page I get "Additional information: The underlying connection was closed: The connection was closed unexpectedly."
Here's my huge ASP.Net webpage (i trimmed everything down to just the line throwing the error):
Imports System.XmlImports System.Net.SocketsPublic Class GetData Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim xmlDoc = XDocument.Load(MyIpAddress) End SubEnd Class
Here's my code for returning the XML:
Private Sub Send(client As Socket, response As String) client.Send(Encoding.UTF8.GetBytes(response), response.Length, SocketFlags.None) End Sub Private Sub SendXML(client As Socket) Dim Mystring As String = "" Mystring = "<?xml version=" & Convert.ToChar(34) & "1.0" & Convert.ToChar(34) & " encoding=" & Convert.ToChar(34) & "UTF-8" & Convert.ToChar(34) & "?>" Mystring += "<DataTable>" Mystring += "<Data>" Mystring += "<Temp1_C>28.0</Temp1_C>" Mystring += "</Data>" Mystring += "</DataTable>" Send(client, Mystring)End Sub
I have added this to my asp.net web.config:
<system.net> <settings> <httpWebRequest useUnsafeHeaderParsing="true" /> </settings> </system.net>
Any thoughts? Thanks!