引起错误的原因是中间需要提交到DTcms.Web\api\payment\balance\index.aspx去处理
导致BasePage.cs中的linkurl方法中 string requestPath = HttpContext.Current.Request.RawUrl.ToLower(); //当前的URL地址
获取到的地址为:/api/payment/balance/index.aspx
解决方法:
1、BasePage.cs中重写linkurl
/// <summary> /// 余额支付专用:返回URL重写统一链接地址 /// </summary> public string linkurl1(string _key,string mobile,params object[] _params) { Hashtable ht = new BLL.url_rewrite().GetList(); //获得URL配置列表 Model.url_rewrite model = ht[_key] as Model.url_rewrite; //查找指定的URL配置节点 //如果不存在该节点则返回空字符串 if (model == null) { return string.Empty; } string requestDomain = HttpContext.Current.Request.Url.Authority.ToLower(); //获得来源域名含端口号 string requestPath = HttpContext.Current.Request.RawUrl.ToLower(); //当前的URL地址 string linkStartString = GetLinkStartString(requestPath, requestDomain); //链接前缀 linkStartString += mobile; //如果URL字典表达式不需要重写则直接返回 if (model.url_rewrite_items.Count == 0) { //检查网站重写状态 if (config.staticstatus > 0) { if (_params.Length > 0) { return linkStartString + GetUrlExtension(model.page, config.staticextension) + string.Format("{0}", _params); } else { return linkStartString + GetUrlExtension(model.page, config.staticextension); } } else { if (_params.Length > 0) { return linkStartString + model.page + string.Format("{0}", _params); } else { return linkStartString + model.page; } } } //否则检查该URL配置节点下的子节点 foreach (Model.url_rewrite_item item in model.url_rewrite_items) { //如果参数个数匹配 if (IsUrlMatch(item, _params)) { //检查网站重写状态 if (config.staticstatus > 0) { return linkStartString + string.Format(GetUrlExtension(item.path, config.staticextension), _params); } else { string queryString = Regex.Replace(string.Format(item.path, _params), item.pattern, item.querystring, RegexOptions.None | RegexOptions.IgnoreCase); if (queryString.Length > 0) { queryString = "?" + queryString; } return linkStartString + model.page + queryString; } } } return string.Empty; }
2、DTcms.Web\api\payment\balance\index.aspx.cs中
Page_Load下加上
string UrlReferrer =string.Empty; string mobile = string.Empty; if (HttpContext.Current.Request.UrlReferrer!=null) UrlReferrer = HttpContext.Current.Request.UrlReferrer.ToString().ToLower(); //来源URL地址 if (UrlReferrer.Contains("mobile")) { mobile = "mobile/"; }
3、DTcms.Web\api\payment\balance\index.aspx.cs中所有的linkurl方法改为例如
Response.Redirect(new Web.UI.BasePage().linkurl1("payment", mobile, "?action=recharge")); //账户的余额不足
原文:http://www.cnblogs.com/qigege/p/5009704.html