Home > Net >  Webapi framework WeChat passive receive less than a reply message
Webapi framework WeChat passive receive less than a reply message

Time:11-11

 
[HttpGet][the Route (" GetByModel ")]//routing path
Public HttpResponseMessage GetByModel (string signature, string timestamp, string nonce, string echostr)
{

Try
{
String EchoStr=valid (token, signature, timestamp, nonce, EchoStr);

if (! String. IsNullOrEmpty (EchoStr))
{
Return ToHttpMsgForWeChat (echostr);
}
The else
{
Return ToHttpMsgForWeChat (" authentication failed!" );
}
}
The catch (Exception ex)
{
Return ToHttpMsgForWeChat (ex. ToString ());
}
}
[HttpPost]
///the Route (" GetByModel ")]//routing path
///& lt; Summary>
///receive messages sent user
///& lt;/summary>
Public void GetByModel ()
{
Try
{
HttpContextBase context=(HttpContextBase) Request. The Properties (" MS_HttpContext ");//get the traditional context
HttpRequestBase request=context. The request;//define traditional request object
HttpResponseBase response=context. The response;
String echostr=request. Params [" echostr "];
String signature=request. Params [" signature "];
String timestamp=request. Params [" timestamp "];
String nonce=request. Params [" nonce "];
//LogHelper WriteLog (" test ");
if (! CheckSignature (token, signature, timestamp, nonce))
{
//WeLogger. Debug (" validation message authenticity - failed!" );
Response. Write (string. The Empty);
The response. The End ();
return;
}
String data=https://bbs.csdn.net/topics/ReadStream2String (request. InputStream);
String responseData=https://bbs.csdn.net/topics/ParseMessage (data);
Response. Write (responseData);
The response. The End ();

}
The catch (Exception ex)
{
//LogHelper WriteLog (ex. ToString ());
}
}



Is a validation WeChat no problem above, the following a not receive information, is there a big help, very urgent, high marks seek help

CodePudding user response:

Below a debugging have to jump in,
  •  Tags:  
  • C#
  • Related