[HttpGet("Return")] public string Return() { QueryString v = Request.QueryString; if (!string.IsNullOrEmpty(v.Value) && v.Value.Length > 1) { string urldata = HttpUtility.UrlDecode(v.Value);//url数据解码 //1.去除第一个前导?字符 Dictionary<string, string> dic = urldata .Substring(1) //2.通过&划分各个参数 .Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries) //3.通过=划分参数key和value,且保证只分割第一个=字符 .Select(param => param.Split(new char[] { '=' }, 2, StringSplitOptions.RemoveEmptyEntries)) //4.通过相同的参数key进行分组 .GroupBy(part => part[0], part => part.Length > 1 ? part[1] : string.Empty) //5.将相同key的value以,拼接 .ToDictionary(group => group.Key, group => string.Join(",", group)); } return DateTime.Now.ToString("yyyyy-MM-dd HH:mm:ss"); }
本文地址 http://www.luofenming.com/show.aspx?id=1f89bcf053884dbaa262292c527a9fea