微信请求的控制get、post方法,是不是一定要加视图?还是可以不加?
为什么服务器上出现找不到视图的警告? public class WeixinController : Controller
    {
        public WeixinController()
        {        }        /// <summary>
        /// 微信后台验证地址(使用Get),微信后台的“接口配置信息”的Url
        /// </summary>
        [HttpGet]
        [ActionName("Index")]
        public ActionResult Get(string signature, string timestamp, string nonce, string echostr)
        {
            var token = "LingZhuo20150716";//微信公众平台后台设置的Token
            if (string.IsNullOrEmpty(token)) return Content("请先设置Token!");
            var ent = "";
            if (!BasicAPI.CheckSignature(signature, timestamp, nonce, token, out ent))
            {
                return Content("参数错误!");
            }
            return Content(echostr); //返回随机字符串则表示验证通过
        }     
        /// <summary>
        /// 用户发送消息后,微信平台自动Post一个请求到这里,并等待响应XML。
        /// </summary>
        [HttpPost]
        [ActionName("Index")]
        public ActionResult Post(string signature, string timestamp, string nonce, string echostr)
        {
            WeixinMessage message = null;
            using (var streamReader = new StreamReader(Request.InputStream))
            {
                message = AcceptMessageAPI.Parse(streamReader.ReadToEnd());
            }
            var response = new WeixinExecutor().Execute(message);
            return new ContentResult
            {
                Content = response,
                ContentType = "text/xml",
                ContentEncoding = System.Text.UTF8Encoding.UTF8
            };
        }
路由到底要怎么设置? public class RouteConfig
    {
        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");            routes.MapRoute(
                name: "Default",
                url: "{controller}/{action}/{id}",
                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            );
        }
    }

解决方案 »

  1.   

    搞了几天,都没有解决,做C/S的做WEB开发,真是头痛,希望大家帮帮忙,谢谢!
      

  2.   

    怎么跟踪?程序编译发布都没问题,直接在浏览器输入http://www.lingzhuogz.com/weixin/weixin?signature=7b8ce4cd8a455a6e70ff31a295aa2452179746e6&timestamp=1405838972&nonce=1482481641 ,也没看到报错。微信就是不好调试,不知怎么调试?
      

  3.   

    在网上下的“超级懒汉编写的基于.NET的微信SDK”的原文件,开始弄的时候还能正常收到订阅、菜单消息,但加了一个控制器后就收不到事件消息了,所有的事件都没反应
    http://www.cnblogs.com/deepleo/p/weixinSDK.html
      

  4.   

    http://www.lingzhuogz.com/weixin/weixin?signature=7b8ce4cd8a455a6e70ff31a295aa2452179746e6&timestamp=1405838972&nonce=1482481641
    这个地址不对吧?
    看你的控制器,应该是
    http://www.lingzhuogz.com/weixin/Index?signature=7b8ce4cd8a455a6e70ff31a295aa2452179746e6&timestamp=1405838972&nonce=1482481641ps,多参数可以放在form里,这种地址太丑了
      

  5.   

    【微信请求的控制get、post方法,是不是一定要加视图?还是可以不加?
    为什么服务器上出现找不到视图的警告?】可以不要加视图,警告的原因应该是针对http://www.lingzhuogz.com/weixin/weixin, WeixinController中有没有weixin名称的action?
      

  6.   

    在此公开你的Token,是件很危险的事情。骚年