Captcha Image在localhost中工作,但在webserver上不起作用

时间:2013-04-25 16:15:20

标签: asp.net vb.net visual-studio-2010 captcha

我正在尝试在UpdatePanel中使用自定义文本验证码。它在localhost上工作正常,但是当我将它部署到Web服务器时,它不会显示。我正在使用VS 2010 - vb.net代码和asp.net 4.0和IIS 6.0在网络服务器上。这是我的代码:

   Private Function GenerateRandomCode() As String 

  'Generate a random number for the CAPTCHA image 
    Dim s As String = "" 
    For i As Integer = 0 To 5 
        s = s + Me.rand.Next(10).ToString() 
    Next 
    Return s 

End Function 

Public Sub SetCaptcha() 
    'Create a new captcha image 
    Me.Session("CaptchaImageText") = GenerateRandomCode() 
    'append current date to image url to assure loading of new image 
    Me.lblResult.ImageUrl = "GetImage.aspx?" + DateTime.Now.ToString() 
End Sub 


Partial Class GetImage 
Inherits System.Web.UI.Page 
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load 

    Response.Cache.SetCacheability(HttpCacheability.NoCache) 
    'Create a CAPTCHA image using the text stored in the Session object. 
    Dim ci As New CaptchaImage.CaptchaImage(Me.Session("CaptchaImageText"), 200, 50, "Century Schoolbook") 

    Me.Response.Clear() 
    Me.Response.ContentType = "image/png" 

    ci.Image.Save(Me.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg) 

    ci.Dispose() 
End Sub 

End Class

enter code here

0 个答案:

没有答案