驗證碼程式
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
public partial class my_ValidateImage : System.Web.UI.Page
{
private readonly string ImagePath = "../images/Validator.jpg";
private static string sValidator = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["Validator"] != null)
{
sValidator = Request.Params["validator"].ToString();
}
Bitmap bitMapImage = new System.Drawing.Bitmap(Server.MapPath(ImagePath));
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
graphicImage.DrawString(sValidator, new Font("Arial", 20, FontStyle.Bold), SystemBrushes.WindowText, new Point(0, 0));
Response.ContentType = "image/jpeg";
//bitMapImage.sava(Response.OutputStream, ImageFormat.Jpeg);
bitMapImage.Save(Response.OutputStream, ImageFormat.Jpeg);
graphicImage.Dispose();
bitMapImage.Dispose();
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
public partial class my_ValidateImage : System.Web.UI.Page
{
private readonly string ImagePath = "../images/Validator.jpg";
private static string sValidator = "";
protected void Page_Load(object sender, EventArgs e)
{
if (Request.Params["Validator"] != null)
{
sValidator = Request.Params["validator"].ToString();
}
Bitmap bitMapImage = new System.Drawing.Bitmap(Server.MapPath(ImagePath));
Graphics graphicImage = Graphics.FromImage(bitMapImage);
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
graphicImage.DrawString(sValidator, new Font("Arial", 20, FontStyle.Bold), SystemBrushes.WindowText, new Point(0, 0));
Response.ContentType = "image/jpeg";
//bitMapImage.sava(Response.OutputStream, ImageFormat.Jpeg);
bitMapImage.Save(Response.OutputStream, ImageFormat.Jpeg);
graphicImage.Dispose();
bitMapImage.Dispose();
}
}
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class my_Default : System.Web.UI.Page
{
static string sValidator = "134";
private readonly string sValidatorImageUrl = "ValidateImage.aspx?Validator=";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Random r = new Random(10);
sValidator = r.Next().ToString();
// sValidator = GetRandomint();
//sValidator = "456789";
// sValidator = GetRandomint();
// sValidator = GetRandomint();
// sValidator = Getrandomint();
// validateimage.ImageUrl = svalidatorImageUrl + svalidator;
//ValidateImage.ImageUrl = sValidatorImageUrl + sValidator;
ValidateImage.ImageUrl = sValidatorImageUrl + sValidator;
// ValidateImage.ImageUrl = "../images/index1.jpg";
}
}
private string GetRandomint()
{
throw new Exception("The method or operation is not implemented.");
}
private string Getrandomint()
{
throw new Exception("The method or operation is not implemented.");
}
protected void Button1_Click(object sender, EventArgs e)
{
int a=0;
if (a < 1)
{
// Response.Write("<script>window.alert('"asdkfkasd"')</script>");
// Response.Write("<script>alert("li")</script>");
return;
}
Response.Redirect("~/default.htm");
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class my_Default : System.Web.UI.Page
{
static string sValidator = "134";
private readonly string sValidatorImageUrl = "ValidateImage.aspx?Validator=";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Random r = new Random(10);
sValidator = r.Next().ToString();
// sValidator = GetRandomint();
//sValidator = "456789";
// sValidator = GetRandomint();
// sValidator = GetRandomint();
// sValidator = Getrandomint();
// validateimage.ImageUrl = svalidatorImageUrl + svalidator;
//ValidateImage.ImageUrl = sValidatorImageUrl + sValidator;
ValidateImage.ImageUrl = sValidatorImageUrl + sValidator;
// ValidateImage.ImageUrl = "../images/index1.jpg";
}
}
private string GetRandomint()
{
throw new Exception("The method or operation is not implemented.");
}
private string Getrandomint()
{
throw new Exception("The method or operation is not implemented.");
}
protected void Button1_Click(object sender, EventArgs e)
{
int a=0;
if (a < 1)
{
// Response.Write("<script>window.alert('"asdkfkasd"')</script>");
// Response.Write("<script>alert("li")</script>");
return;
}
Response.Redirect("~/default.htm");
}
}
每次產生的驗證碼過程,繼續處理中。。。。。。。。
確保產生的驗證碼介於(10000,999999)之間
sValidator = r.Next(100000,999999).ToString();
相關文章
- 生成驗證碼程式程式碼
- 精確驗證身份證號碼程式碼
- 郵箱格式驗證程式碼
- javascript實現的身份證號碼驗證程式碼JavaScript
- jquery 驗證碼效果程式碼例項jQuery
- 驗證碼原理及驗證
- 驗證碼---js重新整理驗證碼JS
- volatile的特性程式碼驗證
- jQuery郵箱格式驗證程式碼jQuery
- Ext實現的身份證格式驗證程式碼
- Java製作驗證碼的完整程式碼Java
- jQuery加法驗證碼效果程式碼例項jQuery
- 驗證手機號碼程式碼簡單程式碼例項
- JavaScript 表單驗證程式碼例項JavaScript
- 郵箱格式驗證程式碼例項
- 郵箱格式驗證程式碼詳解
- 常用的表單驗證程式碼分享
- 【蛤蟆】頁面驗證碼程式(C#)C#
- NT域驗證功能VB典型程式碼
- JavaScript驗證碼生成和驗證效果JavaScript
- javascript實現的驗證碼程式碼例項JavaScript
- QQ號碼驗證正規表示式程式碼
- javascript實現的身份證號碼合法性驗證程式碼JavaScript
- 精確驗證身份證號碼合法性程式碼例項
- 驗證碼機制之驗證碼重複使用
- Laravel - 驗證碼Laravel
- PHP驗證碼PHP
- java身份證驗證程式碼IdcardUtils.java分享Java
- js實現的身份證合法性驗證程式碼JS
- canvas實現的驗證碼效果程式碼例項Canvas
- 驗證手機號碼格式的程式碼例項
- 影片直播app原始碼,傳送驗證碼 驗證碼識別APP原始碼
- 小程式 - 驗證碼倒數計時元件元件
- 郵箱驗證正規表示式程式碼
- javascript驗證郵箱格式程式碼例項JavaScript
- 3個隨機圖片驗證程式碼隨機
- 增加欄位的通用程式碼驗證功能
- PHP 驗證身份證號碼PHP