RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
js刷新验证码(.net)

js刷新验证码:

网站设计制作、成都网站建设的开发,更需要了解用户,从用户角度来建设网站,获得较好的用户体验。创新互联多年互联网经验,见的多,沟通容易、能帮助客户提出的运营建议。作为成都一家网络公司,打造的就是网站建设产品直销的概念。选择创新互联,不只是建站,我们把建站作为产品,不断的更新、完善,让每位来访用户感受到浩方产品的价值服务。


 

//刷新验证码

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
{
    /// 
    /// 用于验证码的处理程序
    /// 调用该处理程序时,要加参数type,表明是哪一个功能需要的验证码
    /// 获取验证码的SessionKey是YK.Website.CheckCode.[type]
    /// 
    public class CheckCodeHandler : IHttpHandler
    {
        public HttpResponse Response
        {
            get
            {
                return HttpContext.Current.Response;
            }
        }
        public HttpRequest Request
        {
            get
            {
                return HttpContext.Current.Request;
            }
        }
        public void Proce***equest(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 = "p_w_picpath/Png";
            Response.BinaryWrite(bytes);
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

把参数的值写成随机数
这样每次点击刷新的时候
缓存就不一样了
就可以起到刷新的效果了

js刷新验证码(.net)


网站标题:js刷新验证码(.net)
转载来源:http://scyingshan.cn/article/jdgshg.html