Last active
April 19, 2018 08:30
-
-
Save joseftw/a81e283820ea6fce14ff762320b7f9ba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NameValueCollectionExtensions { | |
public static string ToQueryString(this NameValueCollection nameValueCollection) { | |
return string.Join("&", nameValueCollection | |
.AllKeys | |
.SelectMany(key => (nameValueCollection.GetValues(key) ?? Enumerable.Empty<string>()) | |
.Select(val => string.Concat(key, "=", WebUtility.UrlEncode(val))))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment