By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,877 Members | 1,100 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,877 IT Pros & Developers. It's quick & easy.

Build Query String Function?

P: n/a
Is there a function in C# to Build a Query String for an HttpRequest?
Like from a NameValue Collection or something?

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
ts******@gmail.com wrote:
Is there a function in C# to Build a Query String for an HttpRequest?
Like from a NameValue Collection or something?


If UTF-8 is acceptable as underlying encoding, Sytem.UriBuilder will do
just fine.

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 19 '05 #2

P: n/a
trival air code:

public string BuildQueryString(NameValueCollection values)
{
StringBuilder sb = new StringBuilder();
for (i =0; i < values; ++ i)
{
sb.Append(i == 0 ? "?" : "&");
sb.Append(values.Keys[i]);
sb.Append("=");
sb.Append(HttpUtility.UrlEncode(values[i]));
}
return sb.ToString();
}

-- bruce (sqlwork.com)
<ts******@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Is there a function in C# to Build a Query String for an HttpRequest?
Like from a NameValue Collection or something?

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.