public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (string.IsNullOrEmpty(_ignoreParameter) || string.IsNullOrEmpty(filterContext.RequestContext.HttpContext.Request.QueryString[_ignoreParameter]))
            {
                if (!BroswerUtility.SideInWeixinBroswer(filterContext.HttpContext))
                {
                    //TODO:判断网页版登陆状态
                    ActionResult actionResult = null;
                    if (!string.IsNullOrEmpty(RedirectUrl))
                    {
                        actionResult = new RedirectResult(RedirectUrl);
                    }
                    else
                    {
                        actionResult = new ContentResult()
                        {
                            Content = _message
                        };
                    }

                    filterContext.Result = actionResult;
                }
            }

            base.OnActionExecuting(filterContext);
        }
コード例 #2
0
        public ActionResult ProductItem(int productId, int hc)
        {
            var products = ProductModel.GetFakeProductList();
            var product  = products.FirstOrDefault(z => z.Id == productId);

            if (product == null || product.GetHashCode() != hc)
            {
                return(Content("商品信息不存在,或非法进入!2003"));
            }

            //判断是否正在微信端
            var userAgent = Request.UserAgent;

            if (BroswerUtility.SideInWeixinBroswer(HttpContext))
            {
                //正在微信端,直接跳转到微信支付页面
                return(RedirectToAction("Index", new { productId = productId, hc = hc }));
            }
            else
            {
                //在PC端打开,提供二维码扫描进行支付
                return(View(product));
            }
        }