I am trying to set the source of images as follows :
private void buttonGet_Click(object sender, RoutedEventArgs e)
{
string website_url =HttpUtility.UrlEncode( textBoxURL.Text);
WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(wc_OpenReadCompleted);
Uri favIconUri = new Uri("http://g.etfv.co/"+ website_url ,UriKind.Absolute);
wc.OpenReadAsync(favIconUri, wc);
}
void wc_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null && !e.Cancelled)
{
try
{
BitmapImage image = new BitmapImage();
image.SetSource(e.Result);
image1.Source = image;
}
catch (Exception ex)
{
//Exception handle appropriately for your app
int i = 0;
}
}
else
{
//Either cancelled or error handle appropriately for your app
}
}
}
I get exception :
{"The request is not supported. "} in line image.SetSource(e.Result);
The text box url is "http://google.com" so the url formed is : "http://g.etfv.co/http%3a%2f%2fwww.google.com" I am unable to figure out a simple thing.
I tried with simple url as "http://img.technospot.net/Windows-Phone-7-Theme-Symbian.jpg" (instead of "http://g.etfv.co/foo-bar" and then it works but not the way I coded.
Anything incorrect ?