asp.net验证码

zhanghang19890621 zhanghang19890621 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
protected void Page_Load(object sender, EventArgs e)
{
Response.BufferOutput = true;
Bitmap img = new Bitmap(100, 100, PixelFormat.Format24bppRgb);
Graphics grh = Graphics.FromImage(img);
grh.Clear(ColorTranslator.FromHtml("#336699"));
grh.FillRectangle(new SolidBrush(Color.Yellow), 200, 200, 200, 200);
grh.DrawString(Show(), new Font("宋体", 20), new SolidBrush(Color.Red), new PointF(50, 50));
//Response.ContentType = "image/Jpeg";
img.Save(Response.OutputStream, ImageFormat.Jpeg);
Response.ContentType = "image/Jpeg";
grh.Dispose();
img.Dispose();
Response.End();

}

protected string Show()
{
string str = "";
Random ran = new Random();
for (int i = 0; i < 4; i++)
{
str += ran.Next(1,10);
}
return str;
}

以上是我做的一个验证码测试

可是页面上面的控件 都不显示了 怎么解决

还有这个验证码一出来就上最上面 怎样把这个验证码定位呢 点击看不清换一张 验证码也会变动
...全文
评论 13
收藏 已收藏
分享
返回顶部
zhanghang19890621
.NET社区 62,275 成员 668,968 内容