1

[ASP.NET 4.0 Visual Studio 2010]

Hi I am new to ASP.NET and am just trying to:

  • Create a Generic Handler so my Server-Side image control can reference it like Image1.ImageUrl = "~/ImageHandle.ashx"

  • Pass the name of a file in my Dropbox account through the query, which is the image file's name (jpeg)

  • Rotate the image and serve it back to my calling code.

But I am really new and this is all I have, I don't know what i am doing wrong.


Public Class ImageHandle
Implements System.Web.IHttpHandler
Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
   Dim imgurl As String = "https://dl.dropbox.com/u/134313/Duel%20Portal%20Info/Images/" & context.Request("file").Replace("_", "%20") 'Number Changed for privacy reasons
    context.Response.ContentType = "image/jpeg"
    Dim img As System.Drawing.Image = Nothing
    Dim webc As New Net.WebClient, theBytes() As Byte
    Try

        theBytes = webc.DownloadData(imgurl)
        img = Byte2Image(theBytes)
        img = Rotate90Degrees(img)

    Catch ex As Exception
    End Try
    img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg)
End Sub
End Class

The image just doesn't show up. ImageHandle hits no breakpoints at all.

Also I have no idea how to format web.config and include this. Help is much appreciated.

EDIT: This is my Web.Config so far. Still not working!! Please help!

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
       <handlers>
           <add name="ImageHandle" path="~/ImageHandle.ashx" verb="*"/>
        </handlers>
 </system.webServer>
seattleite7
  • 350
  • 1
  • 5
  • 15

0 Answers0