Micro-Credit Development (i) asp.net access _ practical skills

Source: Internet
Author: User
Tags sha1 sha1 encryption

To develop a micro-credit, you need to have a server first, but not yourself. At this time can use peanut shells, the intranet map to the public online, so you can access their website in the public network. Specific See: http://www.jb51.net/article/83783.htm

Then write an access code, and only PHP is the sample on the micro-letter. Here is an example of asp.net.

first create a default.aspx. Check in the Page_Load : (MyLog is a log class, can be ignored) about Checksignature () and found that almost. Here, post it.

 Mylog.debuginfo ("request Default.aspx");
 String echostr = request.querystring["Echostr"];
 Mylog.debuginfo ("Echostr:" +echostr);
 if (This.checksignature ())
 {
 if (!string). IsNullOrEmpty (ECHOSTR)) {
 mylog.debuginfo ("echostr:" + echostr);
 Response.Write (ECHOSTR);
 Response.End ();
 }
 
 

The most important thing is the sentence response.end (), do not add this sentence how not to go in (wish to have great God to inform). About Checksignature () is about the same as what was found. Here, post it.

 private bool Checksignature () {String signature = request["signature"];
 string timestamp = request["timestamp"];
 String nonce = request["nonce"];
 Mylog.debuginfo (String.Format ("signature:{0},timestamp:{1},nonce:{2}", signature, timestamp, nonce));
 string token = token;
 string[] Tmparr = new string[] {token, timestamp, nonce};
 Array.Sort (Tmparr); String tmpstr = String.
 Join ("", Tmparr);
 SHA1 encryption System.Security.Cryptography.SHA1 SHA1 = new System.Security.Cryptography.SHA1CryptoServiceProvider ();
 byte[] Secarr = Sha1.computehash (System.Text.Encoding.Default.GetBytes (TMPSTR)); Tmpstr = bitconverter.tostring (Secarr). Replace ("-", "").
 ToLower ();
 Mylog.debuginfo (String.Format ("After parse:{0}", Tmpstr));
 if (tmpstr = = signature) {Mylog.debuginfo ("true");
 return true;
 else {return false; }
}

This is mainly because of the response.end () problem, which led me to a long time, I hereby record the hope to help people who can help.

There is also a point may be due to the micro-mail server token validation failure, more than 2 times, do not like me to only click once Ah!!!

Related Article

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.