Query String Builder V1



public static string BuildUrlWithQueryString(string baseUrl, NameValueCollection parameters) { var queryString = string.Join("&", parameters.AllKeys .Select(key => string.IsNullOrEmpty(parameters[key]) ? HttpUtility.UrlEncode(key) : $"{HttpUtility.UrlEncode(key)}={HttpUtility.UrlEncode(parameters[key])}")); return string.IsNullOrEmpty(queryString) ? baseUrl : $"{baseUrl}?{queryString}"; }

Comments

Popular posts from this blog

Bulk update and delete using SPservice in SharePoint

Javascript function to populate from query string