Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

From Bytes to actual Image displayed on page

Status
Not open for further replies.

ASPNETnewbie

Programmer
May 9, 2006
93
US

I have the code below for a handler. basically what I am trying to do is have the handler extract byte array information saved in Session variable. Process it and then output an image on my page when I set the imageURL of my ImageControl to the address of the handler. Is this not supposed to work? Or does a handler work another way? Is there a better way to get Bytes to display as an image on my .ASPX page?




Code:
<%@ WebHandler Language="VB" Class="ShipLabel" %>

Imports System
Imports System.Web

Public Class ShipLabel : Implements IHttpHandler
    
    Public Sub ProcessRequest(ByVal ctx As HttpContext) Implements IHttpHandler.ProcessRequest

        Dim chartID As String = ctx.Request.QueryString(0)

        ctx.ClearError()
        ctx.Response.Expires = 0
        ctx.Response.Buffer = True
        ctx.Response.Clear()

        Dim memStream As MemoryStream = New MemoryStream(DirectCast(ctx.Session(chartID), Byte()))
        memStream.WriteTo(ctx.Response.OutputStream)
        memStream.Close()

        ctx.Response.ContentType = "image/Jpeg"
        ctx.Response.StatusCode = 200
        ctx.Response.End()

    End Sub

    Public ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
        Get
            Return False
        End Get
    End Property

End Class


thanks in Advance

AspNET
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top