public ActionResult GetValidatorGraphics() { ValidatorCodeTools obj = new ValidatorCodeTools(); string code = obj.CreateValidateCode(5); //采用cookie CookiesHelper.SetCookie("ValidatorCode", code); byte[] graphic = obj.CreateValidateGraphic(code); return(File(graphic, @"image/jpeg")); }
/// <summary> /// 生成验证码数字 /// </summary> /// <param name="id">验证码位数,默认为5</param> /// <returns></returns> public string NewValidateCode(int id = 5) { ValidatorCodeTools obj = new ValidatorCodeTools(); return(obj.CreateValidateCode(5)); }