|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
一般的指的.net就是跟java相对的那种,主要是做企业级应用的。你如果想学这个,主要就是学C#和数据库。(ASP.NET好像很重要的,应该也要学的,ASP.NET上好像可以结合VB和C#等多种语言,但是微软主推C#)办理|成绩|考证码在网上找了一个考证码的源代码,利用后呈现以下成绩:不论你输出准确与否,城市提醒考证码毛病。厥后经由在QQ群里和csdn发贴征询,得知是ie扫瞄器缓存成绩。在经由别人的指导后更正了毛病。源代码以下:
-------------------Validate.aspx------------------
<%@PageLanguage="C#"%>
<%@importnamespace="System"%>
<%@importnamespace="System.IO"%>
<%@importnamespace="System.Drawing"%>
<%@importnamespace="System.Drawing.Imaging"%>
<%@importnamespace="System.Drawing.Drawing2D"%>
<scriptrunat="server">
privateBitmapvalidateimage;
privateGraphicsg;
publicvoidPage_Load(objectSender,EventArgse){
Response.BufferOutput=true;//出格注重
Response.Cache.SetExpires(DateTime.Now.AddMilliseconds(-1));//出格注重
Response.Cache.SetCacheability(HttpCacheability.NoCache);//出格注重
Response.AppendHeader("Pragma","No-Cache");//出格注重
stringVNum=MakeValidateCode();
Session["VNum"]=VNum;//获得考证码,以便厥后考证
ValidateCode(VNum);}
publicvoidValidateCode(stringVNum)
{
validateimage=newBitmap(60,20,PixelFormat.Format24bppRgb);
g=Graphics.FromImage(validateimage);
g.FillRectangle(newLinearGradientBrush(newPoint(0,0),newPoint(110,20),Color.FromArgb(240,255,255,255),Color.FromArgb(240,255,255,255)),0,0,200,200);
g.DrawString(VNum,newFont("arial",11),newSolidBrush(Color.Red),newPointF(6,0));
g.Save();
MemoryStreamms=newMemoryStream();
validateimage.Save(ms,System.Drawing.Imaging.ImageFormat.Gif);
Response.ClearContent();
Response.ContentType="image/bmp";
Response.BinaryWrite(ms.ToArray());
Response.End();
}
stringMakeValidateCode()
{
char[]s=newchar[]{0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z};
stringnum="";
Randomr=newRandom();
for(inti=0;i<5;i++)
{
num+=s[r.Next(0,s.Length)].ToString();
}
returnnum;
}
</script>
-----------------------register.aspx------------
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Register.aspx.cs"Inherits="MyRegister.Register"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>会员注册</title>
<LINKhref="stylesheet.CSS"_fcksavedurl=""stylesheet.css""_fcksavedurl=""stylesheet.css""_fcksavedurl=""stylesheet.css""type="text/css"rel="stylesheet">
</head>
<body>
<formid="form1"runat="server">
<divclass="middle"style="height:1px">
<div>
<asp:LabelID="UserName"runat="server"Text="用户名:"></asp:Label>
<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox>
</div>
<div>
<asp:LabelID="UserPsw"runat="server"Text="暗码:"></asp:Label>
<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox></div>
<div>
<asp:LabelID="Label2"runat="server"Text="确认暗码:"></asp:Label>
<asp:TextBoxID="TextBox6"runat="server"></asp:TextBox></div>
<div>
<asp:LabelID="Question"runat="server"Text="找回暗码成绩:"></asp:Label>
<asp:TextBoxID="TextBox3"runat="server"></asp:TextBox></div>
<div>
<asp:LabelID="Answer"runat="server"Text="找回暗码谜底:"></asp:Label>
<asp:TextBoxID="TextBox4"runat="server"></asp:TextBox></div>
<div>
<asp:LabelID="Email"runat="server"Text="电子邮件:"></asp:Label>
<asp:TextBoxID="TextBox5"runat="server"></asp:TextBox></div>
<div>
<asp:LabelID="Label1"runat="server"Text="考证码:"></asp:Label>
<asp:TextBoxID="CheckCode"runat="server"Width="85px"></asp:TextBox>
<asp:Imageid="Image1"runat="server"ImageUrl="Validate.aspx"></asp:Image></div>
<div>
<asp:ButtonID="Button1"runat="server"Text="断定"/></div>
<divclass="text">
<asp:LabelID="Message"runat="server"></asp:Label></div>
</div>
</form>
</body>
</html>
-------------------------register.aspx.cs-------------------
usingSystem;
usingSystem.Data;
usingSystem.Configuration;
usingSystem.Collections;
usingSystem.Web;
usingSystem.Web.Security;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.WebControls.WebParts;
usingSystem.Web.UI.HtmlControls;
namespaceMyRegister
{
publicpartialclassRegister:System.Web.UI.Page
{
protectedvoidPage_Load(objectsender,EventArgse)
{
}
protectedvoidButton1_Click(objectsender,EventArgse)
{
stringcheckcode=CheckCode.Text;
//Response.Write(Session["VNum"]);
if(checkcode==Session["VNum"].ToString()||Session["VNum"].ToString()==null)//注重Session["VNum"].ToString(),必需加上ToString(),因//为Session["VNum"]是工具。
Response.Redirect("default.aspx");
else
Message.Text="考证码毛病或为空!";
}
}
}
---------------------------------
个中正文的中央应出格注重
以前学了大概半年时间的asp(没有机会做大系统,最多是自己对公司系统做些调整和修改还有一些小程序)。应该说开始接触asp.net是今年元月5号的事。现在很想把公司的系统重新用.net来架构,却不知道如何下手。 |
|