ASP.NET store Image in SQL and retrieve for Asp:Image

前端 未结 7 829
挽巷
挽巷 2020-12-01 17:41

I am looking to fileupload a picture jpeg,gif,etc into an SQL database on an updateprofilepicture page. Then on the profile page, I want to retrieve the image from an sql da

7条回答
  •  無奈伤痛
    2020-12-01 18:13

    The important thing to remember here is that you shouldn't try to transmit the image data with the profile page itself. Instead, you want your profile page to generate HTML markup for the browser that looks something like this:

    User 1234 avatar
    

    That is the ultimate result of your control. Then the browser will send a completely separate Http request to retrieve the image. That's how pictures on web sites work. You then need to be able to handle that additional request. To do that, create an Http handler (*.ashx file) and use it to retrieve the appropriate image data from the database and send it to the browser.

提交回复
热议问题