T
timo
The calling page cannot get the image returned by this generic handler
unless its IsReusable property is set to True. If it is set to False,
the image never displays on the calling page:
Dim img As Web.UI.WebControls.Image
img = CType(Me.FindControl("myimage"), Web.UI.WebControls.Image)
img.ImageUrl = "GetImage.ashx?imagevalue=12345"
Will IsReusable=True cause problems on a busy website, where the image
changes based on dynamic conditions of the user session? The imagevalue
parameter changes all the time.
Thanks
Imports System.Web
Imports System.Web.Services
Public Class GetImage
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
Dim myImageCreator As New ImageCreator
Dim imgvalue As UInt64
imgvalue = Int64.Parse(context.Request("imagevalue").ToString)
Dim imagestream As New System.IO.MemoryStream
myImageCreator.createGif(imagestream, imgvalue)
context.Response.Expires = 0
context.Response.Buffer = False
context.Response.Clear()
context.Response.ClearHeaders()
context.Response.ClearContent()
context.Response.ContentType = "image/gif"
context.Response.BinaryWrite(imagestream.ToArray)
context.Response.Flush()
context.Response.Close()
End Sub
ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class
unless its IsReusable property is set to True. If it is set to False,
the image never displays on the calling page:
Dim img As Web.UI.WebControls.Image
img = CType(Me.FindControl("myimage"), Web.UI.WebControls.Image)
img.ImageUrl = "GetImage.ashx?imagevalue=12345"
Will IsReusable=True cause problems on a busy website, where the image
changes based on dynamic conditions of the user session? The imagevalue
parameter changes all the time.
Thanks
Imports System.Web
Imports System.Web.Services
Public Class GetImage
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements
IHttpHandler.ProcessRequest
Dim myImageCreator As New ImageCreator
Dim imgvalue As UInt64
imgvalue = Int64.Parse(context.Request("imagevalue").ToString)
Dim imagestream As New System.IO.MemoryStream
myImageCreator.createGif(imagestream, imgvalue)
context.Response.Expires = 0
context.Response.Buffer = False
context.Response.Clear()
context.Response.ClearHeaders()
context.Response.ClearContent()
context.Response.ContentType = "image/gif"
context.Response.BinaryWrite(imagestream.ToArray)
context.Response.Flush()
context.Response.Close()
End Sub
ReadOnly Property IsReusable() As Boolean Implements
IHttpHandler.IsReusable
Get
Return True
End Get
End Property
End Class