private string BuildLoginUrl(string returnUrl, HttpRequestBase request) { //return "/login/?returnUrl=" + HttpUtility.UrlEncode(returnUrl); string routeName = ConfigurationManager.AppSettings["LoginRouteName"]; if (string.IsNullOrWhiteSpace(routeName)) { routeName = "Login"; } if (string.IsNullOrWhiteSpace(returnUrl)) { return(RouteHelper.BuildUrl(routeName)); } string x = request.ByWeiXinBrowser() ? HttpUtility.UrlEncode(returnUrl) : returnUrl; // 因为微信会自动解码一次,所以需要编码两次 var url = RouteHelper.BuildUrl(routeName, new { returnUrl = x }); return(url); }