Silverlight 2 Beta 2 - Image Source Bug With QueryString Parameters
(
Jun 30 2008 - 05:06:36 AM by
Timothy Khouri) - [
print blog
post]
Recently, I've been working on an update to a feature for SingingEels while at the same time writing an article on how to build an "image manager" using Silverlight. Because we store images (and thumbnails) in our database, we retrieve them via their ID as a query string parameter. Example:
<a href="Images.aspx?ID=1234" />
This is some very simple code, and there are probably a million articles on how to dynamically retrieve images from a database and display them in a browser.
So, as I was converting our existing functionality into a Silverlight application, I ran into a strange bug. As of right now (Silverlight 2 Beta 2), if you put a query string property in the 'Source' of an 'Image', it'll get ignored. So, if this is your XAML:
<Image Source="Images.aspx?ID=1234" />
Then instead of sending a request to the entire URI, Silverlight chops off everything from the quetion mark onward. Here's a screen-shot of what actually came accross the wire. Notice that the URL doesn't include the query string (as if Silverlight is intentionally truncating it):
Now, to show you that I'm not crazy (and how I got around this issue for my testing purposes). I changed my XAML a little bit to be the following:
<a href="Images.aspx/ID=1234" />
With this simple change in my URL, notice the URL that is being addressed:
Fix The Bug!
My intention for bringing this out isn't to slam Silverlight in any way. It's going to be a great product, and I'm loving it even now. My hope is that someone reads this (who is on the SL dev team), and says "oh yeah, I forgot to fix that"... and then hopefully... they do fix it before launch :)