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!