您目前尚未登陆,请选择【登陆】或【注册
首页->控件插件->Vb.net验证码控件及Demo源码>>WebControlCaptcha/CaptchaImageHandler.vb>>源码在线查看
温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:Vb.net验证码控件及Demo源码
当前文件:文件类型 VBCaptcha/WebControlCaptcha/CaptchaImageHandler.vb打开代码结构图
普通视图
		            
1Imports System 2Imports System.Web 3Imports System.Drawing 4 5''' <summary> 6''' Captcha image stream HttpModule. Retrieves CAPTCHA objects from cache, renders them to memory, 7''' and streams them to the browser. 8''' </summary> 9''' <remarks> 10''' You *MUST* enable this HttpHandler in your web.config, like so: 11''' 12''' &lt;httpHandlers&gt; 13''' &lt;add verb="GET" path="CaptchaImage.aspx" type="WebControlCaptcha.CaptchaImageHandler, WebControlCaptcha" /&gt; 14''' &lt;/httpHandlers&gt; 15''' 16''' Jeff Atwood 17''' http://www.codinghorror.com/ 18'''</remarks> 19Public Class CaptchaImageHandler 20 Implements IHttpHandler 21 22 Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest 23 Dim app As HttpApplication = context.ApplicationInstance 24 25 '-- get the unique GUID of the captcha; this must be passed in via the querystring 26 Dim guid As String = app.Request.QueryString("guid") 27 Dim ci As CaptchaImage = Nothing 28 29 If guid <> "" Then 30 If String.IsNullOrEmpty(app.Request.QueryString("s")) Then 31 ci = CType(HttpRuntime.Cache.Get(guid), CaptchaImage) 32 Else 33 ci = CType(HttpContext.Current.Session.Item(guid), CaptchaImage) 34 End If 35 36 End If 37 38 If ci Is Nothing Then 39 app.Response.StatusCode = 404 40 context.ApplicationInstance.CompleteRequest() 41 Return 42 End If 43 44 '-- write the image to the HTTP output stream as an array of bytes 45 Dim b As Bitmap = ci.RenderImage 46 b.Save(app.Context.Response.OutputStream, Drawing.Imaging.ImageFormat.Jpeg) 47 b.Dispose() 48 app.Response.ContentType = "image/jpeg" 49 app.Response.StatusCode = 200 50 context.ApplicationInstance.CompleteRequest() 51 End Sub 52 53 Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable 54 Get 55 Return True 56 End Get 57 End Property 58 59End Class
还没有找到您心仪的内容?请用.net源码大搜捕
代码片断 打包下载该项目完整源码:Vb.net验证码控件及Demo源码
51Aspx.com 版权所有 CopyRight © 2000-2008. 京ICP备06046876号