Randomly generate a number (ashx file, call the previous write send message code)

Source: Internet
Author: User

public void ProcessRequest (HttpContext context)

{

Message header

String email_title = Dsis.Core.SysCore.PubFunction.DataFilter (Dsis.Core.SysCore.SysFunction.GetParameterInfo (" Email_title ") [" PValue "]);

Context. Response.ContentType = "Text/plain";

The mailbox sent

String Stremail = context. request.querystring["email"];
Send data through the mailbox interface, and then record cookies when successful
Random number
String randdata = Generaterandomnumber (6);
Dsis.Core.BizCore.Email.SendTo (Stremail, Email_title, "You are receiving the verification code through the mailbox, the verification code is" + Randdata);
HttpCookie cookie = new HttpCookie ("Emailrandcode");
Cookies. Values.add ("Checkcode", randdata);
Cookies. Values.add ("Curdatetime", System.DateTime.Now.ToString ());
Cookies. Expires.addseconds (60);
Context. Response.appendcookie (cookie);
}
private static char[] constant =
{
' 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 ',
' 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 '
};
public static string Generaterandomnumber (int Length)
{
System.Text.StringBuilder newrandom = new System.Text.StringBuilder (10);//62);
Random rd = new random ();
for (int i = 0; i < Length; i++)
{
Newrandom.append (constant[rd. Next (10)]); (//62)]);
}
return newrandom.tostring ();
}
public bool IsReusable
{
Get
{
return true;
}

}

Randomly generate a number (ashx file, call the previous write send message code)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.