• 31rbcom,31rbcom【官网】》》》

  • 发布时间:2016-01-13 01:30 | 作者:yc | 来源:互联网 | 浏览:1200 次
  • 31rbcom,31rbcom【官网】》》》

    js改写验证码:

    //改写验证码

    function changeImg() {

    document.getElementById("imgcode").src = "Handler/CheckCodeHandler.ashx?type=login&stamp=" + Math.random();

    31rbcom,31rbcom【官网】》》》

    }

    CheckCodeHandler.ashx

    using System;

    using System.Web;

    namespace YK.WebSite.Handler

    {

    ///

    /// 用于验证码的处置惩罚法度榜样

    /// 调用该处置惩罚法度榜样时,要加参数type,标明是哪一个功用需求的验证码

    /// 获取验证码的SessionKey是YK.Website.CheckCode.[type]

    ///

    public class CheckCodeHandler : IHttpHandler

    {

    public HttpResponse Response

    {

    get

    {

    return HttpContext.Current.Response;

    }

    }

    public HttpRequest Request

    {

    gewww484848comt

    {

    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.Swww.95zz11.cometDataBySession("YK.Website.CheckCode." + type, chkCode);

    Response.ClearContent();

    Response.ContentType = "image/Png";

    Response.BinaryWrite(bytes);

    }

    public bool IsReusable

    {

    get

    {

    return false;

    }

    }

    }

    }

    把参数的值写成随机数

    这么每次点击改写的时分

    缓存就不相同了

    就可以起到改写的感化了

    650) this.width=650;" src="/html/uploads/allimg/160113/013014JG-1.jpg" title="aa.png" alt="wKiom1YlrUujatZjAAGfZLm3Ar4391.jpg" />

    这篇文章出自 “wennuanyiran” 博客,请必须保存此出处http://dingzhaoqiang.blog.51cto.com//

  • 相关内容

友情链接: