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" />
查看全文
相关阅读:
Js判断是否改动
导入用户数据到Discuz! X3.2 并实现同步登陆
win2003(sp2 x86)+iis6+php-5.3.5-Win32 配置
bblittle.com
Macbook Hbase(1.2.6) 伪分布式安装,Hadoop(2.8.2) ,使用自带zookeeper
LeetCode 696. Count Binary Substrings
LeetCode 637. Average of Levels in Binary Tree
LeetCode 226. Invert Binary Tree
LeetCode 669. Trim a Binary Search Tree
LeetCode 575. Distribute Candies
原文地址:https://www.cnblogs.com/zwl12549/p/964728.html
最新文章
socketserver
time模块,补上之前拉下的作业。
socket流程
日志
关于异常处理
关于MD5解密网站。www.cmd5.com
内置函数二
内置函数一
生成器和生成器表达式,及各种推导式
WPF中TreeView.BringIntoView方法的替代方案
热门文章
单例模式那件小事,看了你不会后悔(转)
C#编写的序列化通用类代码
C# RGB与16进制颜色转换方法
QT+VS
CSharp调用C++编写的DLL的方法
前端开发
Redis 使用记录
linux命令
.net Core 笔记
MVC—Controller分离
Copyright © 2011-2022 走看看