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" />
查看全文
相关阅读:
九.GPIO中断试验3——GPIO中断驱动
十.定时器EPIT——1EPIT的入门
九.GPIO中断试验1——中断原理
九.GPIO中断试验2——通用中断服务程序构成
Django学习笔记〇六——项目2,图书管理系统
博客项目——〇六 添加新文章——富文本编辑器、beautifulsoup的使用
1月7日
1月9日
1月8日
Scala泛型和上下界
原文地址:https://www.cnblogs.com/zwl12549/p/964728.html
最新文章
似乎是发现了asp.net ajaxToolkit中TAB控件的一个BUG
学习SQLSERVER2005高可用性数据库镜像的一些心得
由公司协同工作平台项目引发的Windows Active Directory(活动目录域)的应用问题
真实场景中的SharePoint2010系列(开篇)
Asp.Net Mvc 应用程序如何应对不同的URL地址?????,问题解决了
MOSS2007学习笔记备忘录单点登录(1)"我的网站'?
贴几张我儿子的照片,大家看看可爱不
哈哈,我回来了!
备忘录:Asp.net mvc中的UpLoad小技巧
Html.Label的缺陷及补救办法
热门文章
Asp.Net Mvc 应用程序如何应对不同的URL地址?????
MOSS2007学习笔记备忘录单点登录设置(2)
动态创建ASP.NET AJAX Control Toolkit中的Accordion控件
为ASP.NET MVC配置基于Active Directory的表单认证方式
发个文章 记录一下。。
[Java] Json Bson Gson
使用memoizee缓存函数提升性能,竟引发了indexOf的性能问题
js 缓存视频文件到本地
十.定时器EPIT——2按键消抖
前期准备——2.基本汇编语法
Copyright © 2011-2022 走看看