{"id":1551,"date":"2011-01-27T01:59:45","date_gmt":"2011-01-27T01:59:45","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=1551"},"modified":"2011-01-27T02:03:08","modified_gmt":"2011-01-27T02:03:08","slug":"%e7%ae%80%e5%8d%95%e9%aa%8c%e8%af%81%e7%a0%81","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2011\/01\/27\/%e7%ae%80%e5%8d%95%e9%aa%8c%e8%af%81%e7%a0%81\/","title":{"rendered":"\u7b80\u5355\u9a8c\u8bc1\u7801"},"content":{"rendered":"<pre escaped=\"true\" lang=\"csharp\">\r\n1\uff0c\u751f\u6210\u56fe\u7247\u7c7b\uff1a\r\nusing System;\r\nusing System.Configuration;\r\nusing Share.Data;\r\nusing System.Data.SqlClient;\r\nusing System.Text;\r\nusing System.Data;\r\nusing Share.Utility;\r\nusing System.IO;\r\nusing System.Drawing;\r\nusing System.Drawing.Imaging;\r\nnamespace Web.Class.Constant\r\n{\r\n    \/\/\/ &lt;summary&gt;\r\n    \/\/\/ Summary description for HelpConstant.\r\n    \/\/\/ &lt;\/summary&gt;\r\n    public class VerifyCode : System.Web.UI.Page\r\n    {\r\n        private static string codenum;\r\n        public static string CodeNum\r\n        {\r\n            get { return codenum; }\r\n            set { codenum = value; }\r\n        }\r\n        public static string strRandom(int Ia, int Ib)\r\n        {\r\n            Random rd = new Random(unchecked((int)DateTime.Now.Ticks));\r\n            object i = rd.Next(Ia, Ib);\r\n            return i.ToString();\r\n        }\r\n        public static byte[] GetCode(int Ia, int Ib)\r\n        {\r\n            CodeNum = strRandom(Ia,Ib);\r\n            Bitmap bm = new Bitmap(50, 15, System.Drawing.Imaging.PixelFormat.Format32bppArgb);\r\n            Font f = new Font(\"Lucida Sans Unicode\", 9, FontStyle.Bold);\r\n            Graphics g = Graphics.FromImage(bm);\r\n            Rectangle newRect = new Rectangle(0, 0, 50, 16);\r\n            g.FillRectangle(new SolidBrush(Color.WhiteSmoke), newRect);\r\n            g.DrawString(codenum, f, new SolidBrush(Color.Red), 1, -1);\r\n            MemoryStream mStream = new MemoryStream();\r\n            bm.Save(mStream, ImageFormat.Gif);\r\n            g.Dispose();\r\n            bm.Dispose();\r\n            \r\n            return mStream != null?mStream.ToArray():null;\r\n\r\n        }\r\n\r\n    }\r\n}\r\n\r\n2\uff0c\u8f93\u51fa\uff1a\r\n        Response.ClearContent();\r\n        Response.ContentType = \"image\/GIF\";\r\n        Response.BinaryWrite(VerifyCode.GetCode(10000, 99999));\r\n        Response.End();\r\n3,\u524d\u53f0\u5f15\u7528\uff1a<img decoding=\"async\" src=\"ValidateCode.aspx\" \/>\r\n4\uff0c\u524d\u53f0\u5f55\u5165\u7684\u4e0eVerifyCode.CodeNum\u6bd4\u8f83\u5373\u53ef\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1\uff0c\u751f\u6210\u56fe\u7247\u7c7b\uff1a using System; using System.Configuration; usin [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"class_list":["post-1551","post","type-post","status-publish","format-standard","hentry","category-14"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/1551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=1551"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/1551\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=1551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=1551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=1551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}