I use XmlDataSource like this :

<asp:XmlDataSource ID="xmlDataSource1" runat="Server" DataFile="https://myurl.xml" ></asp:XmlDataSource>

as a datasource to my rotater control.


but i get the following exception all the time :

https://myurl.xml is not a valid virtual path.

Although i tried the link externally and there's an xml file

有帮助吗?

解决方案

Ignore my previous answer. Apparently the XmlDataSource does not like https URLs as the DataFile:

// works
xmlDataSource1.DataFile = "http://code.google.com/feeds/p/google-code-prettify/svnchanges/basic";
// does not work
xmlDataSource1.DataFile = "https://code.google.com/feeds/p/google-code-prettify/svnchanges/basic";

Write a few extra lines of code to download the XML from https source like:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://code.google.com/feeds/p/google-code-prettify/svnchanges/basic");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream()); 
string str = reader.ReadToEnd();
// save it or set it as the .Data property of XmlDataSource
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top