📄 check.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Drawing;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace novel
{
public partial class check : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
#region 生成验证码
if (Session.Contents["validate"] == null)
Session.Add("validate", null);
Random rand = new Random();
string vaildate = rand.Next(1000, 10000).ToString();
Session.Contents["validate"] = vaildate;
System.Drawing.Image image = new System.Drawing.Bitmap(30, 16);
System.Drawing.Graphics formGraphice = System.Drawing.Graphics.FromImage(image);
System.Drawing.Font font = new System.Drawing.Font("Arial", 10, FontStyle.Regular);
System.Drawing.SolidBrush brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
formGraphice.Clear(System.Drawing.Color.White);
System.Drawing.StringFormat format = new System.Drawing.StringFormat();
formGraphice.DrawString(vaildate, font, brush, 0, 00, format);
font.Dispose();
brush.Dispose();
formGraphice.Dispose();
image.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
#endregion
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -