39,117
社区成员




@RequestMapping(value = "auth", method = RequestMethod.GET)
public @ResponseBody String auth(
@RequestParam("signature") String signature,
@RequestParam("timestamp") String timestamp,
@RequestParam("nonce") String nonce,
@RequestParam("echostr") String echostr,
HttpServletRequest req) {
log.info("REQ from {}:{} - {} {} {} {}", req.getRemoteHost(), req.getRemotePort(),
signature, timestamp, nonce, echostr);
public void ProcessRequest(HttpContext context)
{
//string postString = string.Empty;
if (HttpContext.Current.Request.HttpMethod.ToUpper() == "GET")
{
Auth();
}
}
private void Auth()
{
#region 获取关键参数
string token = ConfigurationManager.AppSettings["CorpToken"];//从配置文件获取Token
if (string.IsNullOrEmpty(token))
{
//LogTextHelper.Error(string.Format("CorpToken 配置项没有配置!"));
}
string encodingAESKey = ConfigurationManager.AppSettings["EncodingAESKey"];//从配置文件获取EncodingAESKey
if (string.IsNullOrEmpty(encodingAESKey))
{
//LogTextHelper.Error(string.Format("EncodingAESKey 配置项没有配置!"));
}
string corpId = ConfigurationManager.AppSettings["CorpId"];//从配置文件获取corpId
if (string.IsNullOrEmpty(corpId))
{
//LogTextHelper.Error(string.Format("CorpId 配置项没有配置!"));
}
#endregion
string echoString = HttpContext.Current.Request.QueryString["echoStr"];
string signature = HttpContext.Current.Request.QueryString["msg_signature"];//企业号的 msg_signature
string timestamp = HttpContext.Current.Request.QueryString["timestamp"];
string nonce = HttpContext.Current.Request.QueryString["nonce"];
string decryptEchoString = "";
if (CheckSignature(token, signature, timestamp, nonce, corpId, encodingAESKey, echoString, ref decryptEchoString))
{
if (!string.IsNullOrEmpty(decryptEchoString))
{
HttpContext.Current.Response.Write(decryptEchoString);
HttpContext.Current.Response.End();
}
}
}
完全是按照网上的例子放到服务器上的ashx文件 这个有什么问题吗 求教大神