(repost because of SO outage; apologies if the other one re-appears)
I'm building a Silverlight app that will run on Azure. My VS solution has two projects: the web role and the Silverlight. The web role has a Service that works. (I can go to localhost:88/expenseservice.svc/expenses
and get the data I want.)
I am trying to access that data from Silverlight:
private void MainPage_Loaded(object sender, RoutedEventArgs args)
{
WebClient data = new WebClient();
data.DownloadStringCompleted += new DownloadStringCompletedEventHandler(data_DownloadStringCompleted);
Uri dataSource = new Uri("localhost:88/expenseservice.svc/expenses");
data.DownloadStringAsync(dataSource);
}
void data_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
MessageBox.Show(e.Error.InnerException.Message);
return;
}
// ...
}
However, this does not work. The message box shows the error:
The URI prefix is not recognized.
Here is the full exception:
e.Error.InnerException = {System.NotSupportedException: The URI prefix is not recognized.
at System.Net.WebRequest.Create(Uri requestUri)
at System.Net.WebClient.GetWebRequest(Uri address)
at System.Net.WebClient.DownloadStringAsync(Uri address, Object userToken)}
Is it complaining about localhost
? Am I supposed to be doing something differently? Perhaps this is what "Add Service Reference" is for?