Reputation: 826
I have an issue with the following
Dim strPath = String.Concat("http://www.intraneturl.com/xml")
Dim EmpXDoc As New XDocument
EmpXDoc = XDocument.Load(strPath)
above code is working good in the development server(connected to intranet) but after hosting the same to production server(connected to both intranet with proxy and internet with public ip) the above code gives "Unable to connect to remote server" error. But if i try to parse the xml website through client javascript as follows :
var parser = new ActiveXObject("microsoft.xmldom");
parser.load("http://www.intraneturl.com/xml");
nodes = parser.documentElement.childNodes;
it works flawlessly.
Which means that the parser is working in client javascript but not in aspx pages (after host). Will some one guide me ?
Upvotes: 0
Views: 1108
Reputation: 63105
if you have proxy, set the proxy when you load the document
WebProxy wp = new WebProxy(ProxyAddress);
wp.Credentials = new NetworkCredential(ProxyUsername, ProxyPassword);
WebClient wc = new WebClient(){ Proxy =wp};
MemoryStream ms = new MemoryStream(wc.DownloadData("http://www.intraneturl.com/xml"));
XmlTextReader rdr = new XmlTextReader(ms);
EmpXDoc = XDocument.Load(rdr);
Upvotes: 1
Reputation: 56727
Well, in one case the parsing takes place on the client (JavaScript), which may not have an internet connection, so it can successfully resolve the intranet url.
The other code runs on the server, which - being connected both internally and externally - may think the intranet url is an extranet url and thus may not be able to resolve it.
You could try to use an IP-Address in your URL to prevent a DNS request.
Upvotes: 1