2

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

Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
Anyname Donotcare
  • 11,113
  • 66
  • 219
  • 392
  • In fact, `XmlDataSource` works fine with `http` urls but it did not work with `https` URL -- got the exact same error you mentioned. – Salman A Mar 05 '12 at 20:07

1 Answers1

5

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
Salman A
  • 262,204
  • 82
  • 430
  • 521