protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Request["echoStr"]))
{
var echostr = Request["echoStr"];
if (checkSignature() && !string.IsNullOrEmpty(echostr))
{
Response.Write(echostr);//推送
Response.End();
}
}
}
public bool checkSignature()
{
var signature = Request["signature"];
var timestamp = Request["timestamp"];
var nonce = Request["nonce"];
var token = "你的Token值";
string[] ArrTmp = { token, timestamp, nonce };
Array.Sort(ArrTmp); //字典排序
string tmpStr = string.Join("", ArrTmp);
tmpStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
tmpStr = tmpStr.ToLower();
if (tmpStr == signature)
{
return true;
}
else
{
return false;
}
}
{
if (!string.IsNullOrEmpty(Request["echoStr"]))
{
var echostr = Request["echoStr"];
if (checkSignature() && !string.IsNullOrEmpty(echostr))
{
Response.Write(echostr);//推送
Response.End();
}
}
}
public bool checkSignature()
{
var signature = Request["signature"];
var timestamp = Request["timestamp"];
var nonce = Request["nonce"];
var token = "你的Token值";
string[] ArrTmp = { token, timestamp, nonce };
Array.Sort(ArrTmp); //字典排序
string tmpStr = string.Join("", ArrTmp);
tmpStr = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "SHA1");
tmpStr = tmpStr.ToLower();
if (tmpStr == signature)
{
return true;
}
else
{
return false;
}
}