Click here to Skip to main content
15,919,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, i have a webform where i'm trying to get data from a XML URL.
It works when i read the XML file from my local project but not when i try to read from the URL.
What am i doing wrong here?

What I have tried:

This works:

protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("MynewXML.xml"));
DetailsView2.DataSource = ds.Tables[0].DefaultView;
DetailsView2.DataBind();
}

This does not work:

protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath("http://myservername.mydomain.com/my-services/user/MynewXML.xml"));
GridView4.DataSource = ds.Tables[0].DefaultView;
GridView4.DataBind();
}
Posted
Updated 14-Sep-16 21:49pm

1 solution

Quote:
C#
ds.ReadXml(Server.MapPath("http://myservername.mydomain.com/my-services/user/MynewXML.xml"));
When a file over internet, you can't just open it and read, because it is not available to you.
You first need to download the file from server.
 
Share this answer
 
Comments
Kristian_dk 15-Sep-16 4:38am    
okay, point taken! Thanks for helping out

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900