Introduction to asp.net access method for WeChat development

Source: Internet
Author: User
We need to develop a public platform. The first step is to have a public account. What? I don't know what the public account is. it seems that you have to go back to the furnace for refining. In layman's terms, our platform is like a Big Society with individual people and various organizations. We need to develop a public platform. The first step is to have a public account. What? I don't know what the public account is. it seems that you have to go back to the furnace for refining. In layman's terms, our platform is like a Big Society with individual people and various organizations.

To develop, you must first have a server, but you do not have one. At this time, you can use a peanut shell to map the intranet to the public network, so that you can access your own website on the public network.

Then write an access code, and only php is an example. The example of asp.net is attached here.

First create a Default. aspx. Check in Page_Load: (MyLog is a log class and can be ignored.) checkSignature () is similar to the one found. Paste it here

 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 (). If you do not add this sentence, you will not be able to get it in. (I hope you can tell me ). CheckSignature () is similar to the one found. Paste it here

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 encrypts the 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 that caused me to do it for a long time. I would like to record it and hope to help people.

Another reason may be that the Token verification failed because of the server. just click it twice. don't just click it once like me !!!

The above is the detailed introduction to the development of asp.net access methods. For more information, see other related articles on php Chinese network!

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.