Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

WwWXxX, udp high ports, d-link extract firmware dsl-2750u, wwwwxxxxx.2G, yxxxcom, WWWXXX,, wwwxxx 100, www.xxxcon, wwwxxx



#1: IHttpAsyncHandler outputting ashx directive

Posted on 2008-04-24 22:44:00 by ghause

I'm trying to stream in image from another domain asynchronously.
My ashx looks like this:
<%@ WebHandler Language="VB" Class="Handlers.AsyncImageHandler" Debug="true"

Here is the vb:

Namespace .Handlers

Public Class AsyncImageHandler
Implements System.Web.IHttpAsyncHandler

Private _context As HttpContext
Private _webreq As HttpWebRequest

Sub ProcessRequest(ByVal context As HttpContext) _
Implements System.Web.IHttpHandler.ProcessRequest
Throw New InvalidOperationException()
End Sub

Function BeginProcessRequest(ByVal context As HttpContext, ByVal cb
As AsyncCallback, ByVal extraData As Object) As IAsyncResult _
Implements System.Web.IHttpAsyncHandler.BeginProcessRequest

' Save a reference to the HttpContext
_context = System.Web.HttpContext.Current

_webreq =
DirectCast(WebRequest.Create(" r/images/fcicons/shra20.jpg"), HttpWebRequest)

Return _webreq.BeginGetResponse(cb, extraData)
End Function

Sub EndProcessRequest(ByVal result As IAsyncResult) _
Implements System.Web.IHttpAsyncHandler.EndProcessRequest
Dim response As HttpWebResponse =
CType(_webreq.EndGetResponse(result), HttpWebResponse)
Dim Image As Byte()

Image =
getImageByteArray(System.Drawing.Image.FromStream(response.G etResponseStream()))
_context.Response.ContentType = "image/jpeg"
_context.Response.AddHeader("Vary", "User-Agent")

_context.Response.OutputStream.Write(Image, 78, Image.Length
- 78)

End Try
End Sub

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

Private Function getImageByteArray(ByVal image As
System.Drawing.Image) As Byte()
Dim ms As New MemoryStream()
image.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg)
Return ms.ToArray()
End Function
End Class
End Namespace

The baffiling response content (in text format) looks like this:

<%@ WebHandler Language="VB" Class="Handlers.AsyncImageHandler" Debug="true"

What could I be doing that is sending the handler directive in the response?

Report this message