/// <summary> /// 获取带有返回参数的Url /// </summary> /// <param name="url"></param> /// <param name="returnUrl">未通过UrlEncode的参数值</param> /// <param name="channelId"></param> /// <returns></returns> public static string GetReturnUrl(this string url, string returnUrl = "", string channelId = "") { if (string.IsNullOrEmpty(url)) { return(""); } if (!string.IsNullOrEmpty(channelId)) { url = url.GetChannelRouteUrl(channelId); } if (string.IsNullOrEmpty(returnUrl)) { try { returnUrl = HttpContext.Current.Request.RawUrl; } catch { } } if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = UrlParameterHelper.UrlEncode(returnUrl); return(SpliceUrl(url, "returnUrl", returnUrl)); } return(url); }
/// <summary> /// 获取参数,并以“参数名=参数值”的形式组成数组 /// </summary> /// <param name="method">GET/POST</param> /// <returns></returns> public static SortedDictionary <string, string> GetRequest(string method = "GET") { SortedDictionary <string, string> sArray = new SortedDictionary <string, string>(); NameValueCollection coll = null; if (string.Compare(method, "POST", true) == 0) { coll = HttpContext.Current.Request.Form; } else { coll = HttpContext.Current.Request.QueryString; } if (coll != null) { string[] keys = coll.AllKeys; if (keys != null && keys.Length > 0) { for (int i = 0; i < keys.Length; i++) { sArray.Add(keys[i], UrlParameterHelper.GetForm(keys[i])); } } } return(sArray); }
public static string EncryptUrl(string url, string key) { if (string.IsNullOrEmpty(url) || string.IsNullOrEmpty(key)) { return(""); } string result = string.Empty; try { result = SecurityHelper.EncryptBase64XorBase64Url(url, key); if (!string.IsNullOrEmpty(result)) { result = UrlParameterHelper.UrlEncode(result); } } catch { } return(result); }
public static string DecryptUrl(string value, string key) { if (string.IsNullOrEmpty(value) || string.IsNullOrEmpty(key)) { return(""); } string url = string.Empty; try { value = UrlParameterHelper.UrlDecode(value); if (!string.IsNullOrEmpty(value)) { url = SecurityHelper.DecryptBase64XorBase64Url(value, key); } } catch { } return(url); }