【问题标题】:How to make image captcha question with asp.net如何使用 asp.net 制作图像验证码问题
【发布时间】:2011-08-13 07:59:55
【问题描述】:

使用 ASP.net Network 4.0 制作图像验证码安全问题的最佳、最有效且最简单的方法是什么

【问题讨论】:

标签: asp.net image security captcha


【解决方案1】:

如果没有必要,不要重新发明轮子。

使用验证码。

这是在 .Net 中的操作方法:

http://code.google.com/apis/recaptcha/docs/aspnet.html

【讨论】:

    【解决方案2】:

    我想你是在问如何让我自己的 asp.net 不使用外部。这是我使用的并且非常有效

      using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Drawing;
    
    public partial class AntiSecuirtyImageDrawPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.returnNumer(); 
        }
    
        private void returnNumer()
        {
    
            Random num1 = new Random();
    
            Random num2 = new Random();
    
            int numQ1 = 0;
    
            int numQ2 = 0;
    
            string QString = null;
    
            numQ1 = num1.Next(1, 90);
    
            numQ2 = num1.Next(1, 9);
    
            QString = numQ1.ToString() + " + " + numQ2.ToString() + " = ";
    
            Session["ABQAnswer"] = numQ1 + numQ2;
    
            Bitmap bitmap = new Bitmap(num1.Next(70, 125), 22);
    
            Graphics Grfx = Graphics.FromImage(bitmap);
    
            Font font = new Font("Arial", 17, FontStyle.Bold, GraphicsUnit.Pixel);
    
            Rectangle Rect = new Rectangle(0, 0, 125, 50);
    
            Grfx.FillRectangle(Brushes.DarkBlue, Rect);
    
            Grfx.DrawRectangle(Pens.PeachPuff, Rect);
    
            // Border
    
            Grfx.DrawString(QString, font, Brushes.White, 0, 0);
    
            Response.ContentType = "Image/jpeg";
    
            bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
    
            bitmap.Dispose();
    
            Grfx.Dispose();
    
        } 
    }
    

    我怎么称呼它

      <div id="ABQImg" style="position: absolute; left: 420px; top: 235px; width: 125px;
                z-index: 44; height: 22px; line-height: 22px; text-align: right;">
                <asp:Image ID="imgABQ" BorderWidth="0px" runat="server" ImageUrl="~/AntiSecuirtyImageDrawPage.aspx" />
            </div>
    

    【讨论】:

      猜你喜欢
      • 2011-12-15
      • 2023-03-15
      • 1970-01-01
      • 2013-12-17
      • 1970-01-01
      • 2011-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多