应用程序中显示的图像不会出现

时间:2013-11-18 08:27:22

标签: asp.net vb.net

我有这个代码ImageHandler。

Public Class ImageHandler : Implements IHttpHandler
   Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpH
    Dim oBJDB As New DBX
    Try
        Dim oSDR As System.Data.SqlClient.SqlDataReader

 oSDR = oBJDB.CreateSDRFromSQLSelect("SELECT SIGNIMAGE FROM APPUSERDTL WHERE UID =@UID")
        If oSDR.Read() Then
            context.Response.BinaryWrite(CType(oSDR("SIGNIMAGE"), Byte()))
            Dim ImageID As New SqlParameter("@UID", Data.SqlDbType.Int)
             ImageID.Value = context.Request.Cookies("UID").Value
        End If
        oSDR.Close()
        oSDR = Nothing
    Catch ex As Exception
    Finally
        oBJDB.Close()
        oBJDB = Nothing
    End Try

End Sub

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

End Class

如果使用此功能,则不会显示应用程序中显示的图像。

请帮帮我

1 个答案:

答案 0 :(得分:0)

将图像控件放在.aspx文件中:

 <asp:Image ID="Image1" runat="server" Height="75px"  Width="76px" />

然后在你的.vb文件中:

      imageId as string=context.Request.Cookies("UID").Value
      Image1.ImageUrl = "~/Profile/ImageHandler.ashx?ImageId= "& imageId

随时联系,不要忘记标记为可以帮助您的答案。