Use a System.Drawing.Image in an HTML tag

前端 未结 4 2061
忘了有多久
忘了有多久 2021-01-14 11:21

I have a potentially easy question. I have an image stored in a database, I then used a C# method in my application that gets that image and stores it in a custom class tha

4条回答
  •  我在风中等你
    2021-01-14 12:06

    If you have to store your images in the database, a simple way to view them would be to use an image handler.

    Basically, you can create an ASHX handler which accepts a query string that is the Image ID in the database and returns the image content along with the correct mime type. This is quite simple to do in C#.

    You can then point the tag to the handler with the specified ID. Something like

    table += String.Format("", ind.myImageId);
    

    Here is a basic tutorial to get you started.

    A common performance improvement would be to cache the images on disk within the handler.

提交回复
热议问题