获取url参数
private static string GetQueryParam(string url,string name) { if (string.IsNullOrWhiteSpace(url)) { return string.Empty; } if(!Regex.IsMatch(url, "(http[s]?:\\/\\/)?([^\\/\\s]+\\/)(.*)",RegexOptions.IgnoreCase)) { return string.Empty; } if (string.IsNullOrWhiteSpace(name)) { return string.Empty; } var query = new Uri(url).Query.TrimStart('?'); if (string.IsNullOrWhiteSpace(query)) { return string.Empty; } Dictionary<string, string> dicQueryString = query.Split('&') .ToDictionary(c => c.Split('=')[0].ToLower(), c => Uri.UnescapeDataString(c.Split('=')[1])); if (!dicQueryString.Keys.Contains(name)) { return string.Empty; } return dicQueryString[name.ToLower()]; }