Demo of ShowImage.aspx

This demo illustrates using the ASP.NET Web page ShowImage.aspx. The following HTML is used in the demo:

<img src="/demos/ShowImage.aspx?img=dgeditss.gif" />



Source Code
Below is the source code for ShowImage.aspx

<%@Import Namespace="System.Drawing.Imaging" %> <script language="VB" runat="server"> Sub Page_Load(sender as Object, e as EventArgs) 'Read in the image filename to create a thumbnail of Dim imageUrl as String = Request.QueryString("img") 'Make sure that the image URL doesn't contain any /'s or \'s If imageUrl.IndexOf("/") >= 0 Or imageUrl.IndexOf("\") >= 0 then 'We found a / or \ Response.End() End If 'Add on the appropriate directory imageUrl = "/images/" & imageUrl 'Get the image. Dim fullSizeImg as System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(Server.MapPath(imageUrl)) 'Set the ContentType to "image/gif" and output the image's data Response.ContentType = "image/gif" fullSizeImg.Save(Response.OutputStream, ImageFormat.Gif) End Sub </script>


[Return to the article]