码迷,mamicode.com
首页 > 微信 > 详细

ASP.NET微信公众平台1-参数配置

时间:2016-10-14 00:08:36      阅读:213      评论:0      收藏:0      [点我收藏+]

标签:

创建一个一般处理程序来实现微信服务器验证
文件名如(WXStudayHandler.ashx)
将文件上传到远程服务器上,开始进行微信公众平台验证

  

技术分享
<%@ WebHandler Language="C#" Class="WXStudayHandler" %>

using System;
using System.Web;
using System.IO;
using System.Xml;
public class WXStudayHandler : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";
        if (context.Request.HttpMethod.ToLower().Equals("get"))
        {
            //微信服务器传递的验证信息
            string signature = context.Request["signature"];
            string timestamp = context.Request["timestamp"];
            string nonce = context.Request["nonce"];
            string echostr = context.Request["echostr"];
            //和微信Token一致
            string token = "test";
            //指定数据排序
            string[] temp = { token, timestamp, nonce };
            Array.Sort(temp);
            string str = string.Join("", temp);
            //SHA1加密
            string strsha1 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "SHA1");
            //对比验证
            if (strsha1.ToLower().Equals(signature.ToLower()))
            {
                context.Response.Write(echostr);
            }
        }
    }
   
    public bool IsReusable {
        get {
            return false;
        }
    }

}
View Code

 

一、登陆微信平台,找到基本配置

 

技术分享

二、修改服务器配置

技术分享

Url:填写上传的.ashx文件服务器地址

保存验证

 

ASP.NET微信公众平台1-参数配置

标签:

原文地址:http://www.cnblogs.com/mrlian/p/5958473.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!