Im trying to get a XML and then response.write it to a page (on my server) so I can get it with an Ajax request (javascript) later.. But when I try this the document comes out as a HTML-page with a node with the XML: https://i.sstatic.net/7Yv9z.jpg
If I go to the url in with my browser it displays the XML correct, so I guess its no erros with the source?
Heres the code thats called on page_load:
public void getXML(){
WebRequest req = WebRequest.Create("url");
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
req.ContentType= "text/xml charset=utf8";
Stream streamdata = resp.GetResponseStream();
StreamReader reader = new StreamReader(streamdata);
string serverresponse = reader.ReadToEnd();
reader.Close();
streamdata.Close();
resp.Close();
Response.Write(serverresponse);
}
What am i missing? (yes im new to this!) tnx
javascript: var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
console.log(xmlhttp.responseXML);
}
}
xmlhttp.open("GET", "http://127.0.0.1:8080/api.aspx?METHOD=getXML",true);
xmlhttp.setRequestHeader("Content-type", "application/xml");
xmlhttp.send();