Search code examples
c#asp.netsilverlight-2.0

Retrieve an image from SQL Server to show it in an ASP.NET app


I want to retrieve an image from SQL Server to show it in an ASP.NET app. I think that I can write down the image retrieved from SQL Server to a server's folder and show it throw its path. Is there any other better way?

I have the same problem with audio and video files (can I use silverlight to play these audio and video files?)

My worry is that I don't want to store these files (images, audios and videos) on server to show it.


Solution

  • You can write a custom HTTP handler that will take ID of the item you are trying to display on the query string parameter.

    This handler will then retrieve the data from SQL Server, and return it just like downloading a file. This post has the steps.

    I am not sure about the capability of Silverlight streaming from a "file", you may need to use Silverlight Streaming Service.