Resize and Display image from server with ASP.NET

后端 未结 5 2028
轮回少年
轮回少年 2021-01-13 17:23

Got a question. I have images hosted on my server. I already know of the method when an image is uploaded to resize it and save, but I have another thought in mind.

<
5条回答
  •  不要未来只要你来
    2021-01-13 17:57

    I assume you can 'control' the urls to the resized images, so for example the full-sized image might be referenced as the thumbnail could be to an ASPX or ASHX like ?

    This article on CodeProject - Dynamic Image Resize seems to have exactly the source code you are looking for (and although it's in VB, it shouldn't be hard to port if you're a C# person). Hope that helps.

    Finally, I'd encourage you consider the various forms of caching (both using Http-Headers, to ensure the images are cached at the client or proxy whenever possible; and using built-in ASP.NET features to avoid unnecessary processing of the same images over-and-over).

    Although you'll be saving disk-quota, you're effectively slowing down every other page/request... just a thought.

提交回复
热议问题