zoukankan
html css js c++ java
httphandler生成验证图
<%
@ WebHandler Language
=
"
C#
"
Class
=
"
image
"
%>
using
System;
using
System.Web;
using
System.Drawing;
public
class
image : IHttpHandler,System.Web.SessionState.IRequiresSessionState
{
public
void
ProcessRequest (HttpContext context)
{
context.Response.ContentType
=
"
text/gif
"
;
Bitmap b
=
new
Bitmap(
200
,
60
);
Graphics g
=
Graphics.FromImage(b);
g.FillRectangle(
new
SolidBrush(Color.White),
0
,
0
,
200
,
60
);
Font font
=
new
Font(FontFamily.GenericSansSerif,
48
, FontStyle.Bold, GraphicsUnit.Pixel);
Random r
=
new
Random();
string
letters
=
"
ABCDEFGHIJKMNPQRSTUVWXYX
"
;
string
letter;
System.Text.StringBuilder s
=
new
System.Text.StringBuilder();
for
(
int
x
=
0
; x
<
5
; x
++
)
{
letter
=
letters.Substring(r.Next(
0
, letters.Length
-
1
),
1
);
s.Append(letter);
g.DrawString(letter, font,
new
SolidBrush(Color.Black), x
*
38
, r.Next(
0
,
15
));
}
Pen linePen
=
new
Pen(
new
SolidBrush(Color.Black),
2
);
for
(
int
x
=
0
; x
<
6
; x
++
)
{
g.DrawLine(linePen,
new
Point(r.Next(
0
,
199
), r.Next(
0
,
59
)),
new
Point(r.Next(
0
,
199
), r.Next(
0
,
59
)));
}
b.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Gif);
context.Session[
"
aaa
"
]
=
s.ToString();
context.Response.End();
}
public
bool
IsReusable
{
get
{
return
false
;
}
}
}
<img src="image.ashx" />
查看全文
相关阅读:
mysql中InnoDB存储引擎的行锁和表锁
阿里云出海 埃森哲护航
阿里云出海 埃森哲护航
阿里云出海 埃森哲护航
阿里云出海 埃森哲护航
Python开发简单爬虫
Python开发简单爬虫
Python开发简单爬虫
Python开发简单爬虫
问大家一个问题,如何用1万元创业,每天利润达到500元?
原文地址:https://www.cnblogs.com/zwl12549/p/964728.html
最新文章
MySQL Change Data Directory
MySQL Change Data Directory
MySQL Change Data Directory
python接口自动化测试(六)-unittest-单个用例管理
python接口自动化测试(六)-unittest-单个用例管理
python接口自动化测试(六)-unittest-单个用例管理
python接口自动化测试(六)-unittest-单个用例管理
mysql中InnoDB存储引擎的行锁和表锁
mysql中InnoDB存储引擎的行锁和表锁
对于工薪阶层,创业可能吗?
热门文章
当你什么都不会的时候,你想创业该怎么做?
创业者适合做小程序吗?企业应如何提前布局小程序?
在小县城适合做什么生意?
为什么那么多人宁愿拿死工资,也不愿意做小生意?
极速收藏!巨详细的分布式架构知识体系
eureka 和zookeeper 区别 优势
CAP原则(CAP定理)、BASE理论
目前最适合农村创业、投资少、风险低、前景好的项目有哪些?
手里有三十多万,投资干点什么好呢?
mysql中InnoDB存储引擎的行锁和表锁
Copyright © 2011-2022 走看看