Created
June 23, 2018 19:25
-
-
Save musoftware/4ca7c5c146cf491cede648b403cb74ea to your computer and use it in GitHub Desktop.
NameValueCollection to postData
This file contains hidden or 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
using System.Collections.Generic; | |
using System.Collections.Specialized; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Web; | |
public static class Extensions | |
{ | |
public static string ToPostData(this NameValueCollection @this) | |
{ | |
StringBuilder post = new StringBuilder(); | |
foreach (var item in @this.AllKeys) | |
{ | |
post.AppendFormat("&{0}={1}", item, HttpUtility.UrlEncode(@this[item])); | |
} | |
string postData = post.ToString().Trim('&'); | |
return postData; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment