ASPNETnewbie
Programmer
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