This is a migrated thread and some comments may be shown as answers.

retrieving images from database

5 Answers 167 Views
CoverFlow
This is a migrated thread and some comments may be shown as answers.
Christian Devita
Top achievements
Rank 1
Christian Devita asked on 08 Apr 2009, 09:44 PM
I am trying to use coverflow with images from a database.

I am trying to do this with an http handler i already have created in my web app called GetImage.ashx which retrieves an image bytes from a sql database and returns it as a jpeg image

I cannot seem to get it to work.  It just gives me a thumbnail saying 'error loading image' in the silverlight control when i test it.

I suspect there is a built-in check for the file extension since the control doesnt even get a chance to call the handler.

Is there way to do this?

Here is the example xaml

<

 

UserControl xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" x:Class="CosySlideShow.Page"

 

 

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

 

 

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

 

 

Width="500" Height="500">

 

 

 

<Grid x:Name="LayoutRoot" Background="White">

 

 

 

<telerikNavigation:RadCoverFlow x:Name="RadCoverFlow1" Width="500" Height="500" CameraY="-150" ItemMaxHeight="100">

 

 

 

<Image Source="GetImage.ashx?Id=1" />

 

<Image Source="GetImage.ashx?Id=2" />

 

<Image Source="GetImage.ashx?Id=3" />

 

 

 

<Image Source="GetImage.ashx?Id=4" />

 

 

 

<

 

Image Source="GetImage.ashx?Id=5" />

 

 

 

 

 

 

</telerikNavigation:RadCoverFlow>

 

 

 

</Grid>

 

</

 

UserControl>

 

5 Answers, 1 is accepted

Sort by
0
Miroslav Nedyalkov
Telerik team
answered on 09 Apr 2009, 03:35 PM
Hi Christian Devita,

The control doesn't perform such a check. This should work fine like this.
Could you please try to trace with some tool (firebug for example) what happens with the request - is it sent at all, is the string correct, does it fail or succeed, etc.

Regards,
Miroslav Nedyalkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian Devita
Top achievements
Rank 1
answered on 09 Apr 2009, 04:53 PM
I also tried renaming a jpeg's file extension from jpg to txt and got the same result which leads me to believe there is something going on with filename itself.

I am half way done retooling my http handler to work on all files with .jpg extensions

I am going to try that approach and see if it works.

Thanks
0
Miroslav Nedyalkov
Telerik team
answered on 10 Apr 2009, 03:38 PM
Hello Christian Devita,

Renaming the files to .jpg doesn't work, because the web server associates with them MIME type text/plain to the image and the Silverlight doesn't try to read it as an image. This makes me think that the service doesn't associates correct MIME type to the image when sends it. Try to open these image directly from the browser and to investigates the HTTP headers that are sent.
Hope this helps.

Regards,
Miroslav Nedyalkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian Devita
Top achievements
Rank 1
answered on 10 Apr 2009, 04:15 PM
I ran a Web Debugging Proxy (Fiddler) and the content-type from my handler is 'image/pjpeg'

I did get it to work by creating a new image handler that works on any request for files ending in '.jpg'. This new handler first checks to see if the file requested really exists ( which then sends the image to the requesting client) or if it does not exist it tries to parse the filename and use that info to retrieve a matching image from the database.

The only difference between this approach and the one i was using before ( a handler called GetImage.ashx) is that instead of parsing a querystring for the image ID i now parse the filename for the image ID.

I am not sure why this approach works but it does.

thanks
0
Miroslav Nedyalkov
Telerik team
answered on 10 Apr 2009, 04:42 PM
Hi Christian Devita,

I'm happy that you solved the problem.

Best wishes,
Miroslav Nedyalkov
Tags
CoverFlow
Asked by
Christian Devita
Top achievements
Rank 1
Answers by
Miroslav Nedyalkov
Telerik team
Christian Devita
Top achievements
Rank 1
Share this question
or