# VBForums CodeBank > CodeBank - ASP / ASP.NET / MVC / Web API >  ASP.NET - return a code drawn image

## Phill64

This is an example of how to make an .aspx page return an image, so that you can do for example (IMG SRC='\codepage.aspx' /), you probably came here from the link in my signature so no more explanation required  :Roll Eyes (Sarcastic):  

and if not (or if ive removed it, this is it):


Ok, so the code that makes that page is this(on the load event):


```
        'use GDI+ to crate a bitmap canvas and graphics
        Dim bit As New Bitmap(300, 15)
        Dim g As Graphics = Graphics.FromImage(bit)
        g.Clear(Color.FromArgb(241, 241, 241)) 'using forums colour
        'draw something o nthe bitmap
        g.DrawString("Your IP is: " & Me.Request.UserHostAddress & "  <- learn how", New Font(FontFamily.GenericSansSerif, 10, FontStyle.Underline), New SolidBrush(Color.Blue), 0, 0)

        'wipe out return content (which is normally a webform)
        Me.Response.ClearContent()
        Me.Response.ClearHeaders()
        'make response type an image (and we're going to use a PNG)
        Me.Response.ContentType = "image/png"

        'make a memorystream to put the image bytes into
        Dim temp As New IO.MemoryStream
        'save the image to the memorystream
        bit.Save(temp, Imaging.ImageFormat.Png)
        'write the bytes from our memory stream, to the response of our webpage (so send it to the browser)
        Me.Response.BinaryWrite(temp.ToArray)
        'finish up
        Me.Response.End()
```

Enjoy.

----------


## pit_bait

> This is an example of how to make an .aspx page return an image, so that you can do for example (IMG SRC='\codepage.aspx' /), you probably came here from the link in my signature so no more explanation required  
> 
> and if not (or if ive removed it, this is it):
> 
> 
> Ok, so the code that makes that page is this(on the load event):
> 
> 
> ```
> ...


hi,

Did you try this code in .net 2005?

tnx

----------

