Пример #1
0
        /// <summary>
        /// 用于form表单
        /// </summary>
        /// <param name="action">要跳转的action,不带?号</param>
        /// <param name="Request">当前页面Request</param>
        /// <param name="param">需要附加的参数,不要以?或&开头</param>
        public static string GetAction(string action, HttpRequest Request, string param = "")
        {
            string query = "";

            if (Request.Query.Count > 0)
            {
                foreach (var item in Request.Query)
                {
                    query += string.Format("{0}={1}&", SafeSC.RemoveBadChar(item.Key), HttpUtility.UrlEncode(SafeSC.RemoveBadChar(Request.Query[item.Key])));
                }
                query = "?" + query.TrimEnd('&');
            }
            if (!string.IsNullOrEmpty(param))
            {
                query = string.IsNullOrEmpty(query) ? "?" + param : query + "&" + param;
            }
            return(action + query);
        }