/// <summary> ///filter out unnecessary parameters in the address/// </summary> /// <param name= "url" >Address</param> /// <param name= "ParamName" >Name of parameter</param> /// <returns></returns> Public stringFilterurlparam (stringUrlstringparamname) { stringstr =""; if(URL.) ToLower (). IndexOf ("?") != -1) {str= URL. Substring (URL. ToLower (). IndexOf ("?") +1); } Else { returnURL; } string[] arr =New string[] { }; stringReturnUrl =""; if(URL.) ToLower (). IndexOf ('&') != -1) {arr= str. Split ('&'); for(inti =0; I < arr. Length; i++) { if(I <arr. Length) {if(Arr[i]. Split ('=')[0]. ToLower ()! =paramname) {ReturnUrl= ReturnUrl + arr[i]. Split ('=')[0] +"="+ Arr[i]. Split ('=')[1] +"&"; } } } returnUrl. Substring (0Url. IndexOf ('?')) +"?"+ ReturnUrl. Substring (0, ReturnUrl. Length-1); } Else{arr= str. Split ('='); if(arr[0]. ToLower () = =paramname) { returnUrl. Substring (0Url. IndexOf ('?')); } Else { returnURL; } } }
Filter out unwanted parameters in the URL in the background