JS Refresh Verification Code:
<a href= "javascript:changeimg ();" Style= "color:red; font-size:12px; Text-decoration:none, "title=" can't see clearly? Click to change "> </a>
Refresh Verification Code
function changeimg () {document.getElementById ("Imgcode"). src = "Handler/checkcodehandler.ashx?type=login&stamp = "+ Math.random (); }
checkcodehandler.ashx
Using system;using system.web;namespace yk. website.handler{ /// <summary> /// handler for verification code /// when the handler is called, the parameter type is added to indicate which function requires the verification code /// The sessionkey that gets the verification code is YK.Website.CheckCode. [type] /// </summary> public class checkcodehandler : ihttphandler { public HttpResponse Response { get { return HttpContext.Current.Response; } } public httprequest request { get { return HttpContext.Current.Request; } } public void processrequest (HttpContext context) { string type = request.querystring["Type"]; if (String.isnullorwhitespace (type)) return; Response.Buffer = true; response.expiresabsolute = system.datetime.now.addmilliseconds (0 ); response.expires = 0; Response.CacheControl = " No-cache "; response.appendheader (" Pragma ", " No-cache "); string chkcode = string.empty; byte[ ] bytes = yk. Common.Util.CheckCodeKit.GetChkCodeBytes (Ref chkcode); yk. Core.Context.Context.SetDataBySession ("YK. Website.checkcode. " + type, cHkcode); response.clearcontent (); Response.ContentType = "Image/png" ; response.binarywrite (bytes); } public bool IsReusable { get { return false; } } }}
Write the value of the parameter as a random number
So every time I click Refresh,
The cache is different.
It's going to be a refreshing effect.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/AA/wKiom1YlrUujatZjAAGfZLm3Ar4391.jpg "title=" aa.png "alt=" Wkiom1ylruujatzjaagfzlm3ar4391.jpg "/>
This article is from the "Wennuanyiran" blog, make sure to keep this source http://dingzhaoqiang.blog.51cto.com/5601059/1704443
JS Refresh Verification Code (. NET)