retrieving images from database

6 posts, 0 answers
  1. Christian Devita
    Christian Devita avatar
    31 posts
    Member since:
    Jun 2005

    Posted 08 Apr 2009 Link to this post

    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>

     

  2. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 09 Apr 2009 Link to this post

    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.
  3. DevCraft banner
  4. Christian Devita
    Christian Devita avatar
    31 posts
    Member since:
    Jun 2005

    Posted 09 Apr 2009 Link to this post

    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
  5. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 10 Apr 2009 Link to this post

    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.
  6. Christian Devita
    Christian Devita avatar
    31 posts
    Member since:
    Jun 2005

    Posted 10 Apr 2009 Link to this post

    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
  7. Miroslav Nedyalkov
    Admin
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 10 Apr 2009 Link to this post

    Hi Christian Devita,

    I'm happy that you solved the problem.

    Best wishes,
    Miroslav Nedyalkov
Back to Top
DevCraft banner