js刷新验证码:
& lt; a href=" javascript: changeImg ();“,, title=翱床磺迓?点击换一张”比; ,& lt; img id=癷mgcode”, src=" https://www.yisu.com/zixun/Handler/CheckCodeHandler.ashx?type=login&stamp=1 ",宽度=" 80 ",身高=" 30 ",onclick=" changeUrl()/比; & lt;/a>
//刷新验证码
function changeImg (), { . getelementbyid (“imgcode”)才能.src =,“处理程序/CheckCodeHandler.ashx ?类型=login&邮票=",+,math . random (); 以前,}>
CheckCodeHandler。以前ashx
using 系统; using 包含; namespace YK.WebSite.Handler { ,,,///,& lt; summary> ,,,///,用于验证码的处理程序 ,,,///,调用该处理程序时,要加参数类型,表明是哪一个功能需要的验证码 ,,,///,获取验证码的SessionKey是YK.Website.CheckCode。(类型) ,,,///,& lt;/summary> ,,,public class CheckCodeHandler : IHttpHandler ,,,{ ,,,,,,,public HttpResponse 响应 ,,,,,,,{ ,,,,,,,,,,, ,,,,,,,,,,,{ ,,,,,,,,,,,,,,,return HttpContext.Current.Response; ,,,,,,,,,,,} ,,,,,,,} ,,,,,,,public HttpRequest 请求 ,,,,,,,{ ,,,,,,,,,,, ,,,,,,,,,,,{ ,,,,,,,,,,,,,,,return HttpContext.Current.Request; ,,,,,,,,,,,} ,,,,,,,} ,,,,,,,public void 过程* * *装备(HttpContext 上下文) ,,,,,,,{ ,,,,,,,,,,,string type =, Request.QueryString(“类型”); ,,,,,,,,,,,if (String.IsNullOrWhiteSpace(类型),返回; ,,,,,,,,,,,Response.Buffer =,真的; ,,,,,,,,,,,Response.ExpiresAbsolute =, System.DateTime.Now.AddMilliseconds (0); ,,,,,,,,,,,Response.Expires =, 0; ,,,,,,,,,,,Response.CacheControl =,“no - cache”; ,,,,,,,,,,,Response.AppendHeader(“杂注”,“no - cache”); ,,,,,,,,,,,string chkCode =, String.Empty; ,,,,,,,,,,,byte [], bytes =, YK.Common.Util.CheckCodeKit.GetChkCodeBytes (ref chkCode); ,,,,,,,,,,,YK.Core.Context.Context.SetDataBySession (“YK.Website.CheckCode。”, +,类型,chkCode); ,,,,,,,,,,,Response.ClearContent (); ,,,,,,,,,,,Response.ContentType =,“p_w_picpath/Png”; ,,,,,,,,,,,Response.BinaryWrite(字节); ,,,,,,,} ,,,,,,,public bool IsReusable ,,,,,,,{ ,,,,,,,,,,, ,,,,,,,,,,,{ ,,,,,,,,,,,,,,,return 假; ,,,,,,,,,,,} ,,,,,,,} ,,,} }
把参数的值写成随机数
这样每次点击刷新的时候
缓存就不一样了
就可以起到刷新的效果了