本文整理汇总了C#中System.Collections.Specialized.NameValueCollection.ConstructQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# NameValueCollection.ConstructQueryString方法的具体用法?C# NameValueCollection.ConstructQueryString怎么用?C# NameValueCollection.ConstructQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Specialized.NameValueCollection
的用法示例。
在下文中一共展示了NameValueCollection.ConstructQueryString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendPassword
private static string SendPassword(string username, string encryptedBase64, Dictionary<string, object> loginParams)
{
// Send the RSA-encrypted password via POST.
var webRequest = WebRequest.Create(API_DO_LOGIN) as HttpWebRequest;
webRequest.Method = "POST";
var timestamp = loginParams["timestamp"] as string;
var fields = new NameValueCollection();
fields.Add("username", username);
fields.Add("password", encryptedBase64);
fields.Add("emailauth", String.Empty);
fields.Add("captchagid", String.Empty);
fields.Add("captcha_text", String.Empty);
fields.Add("emailsteamid", String.Empty);
fields.Add("rsatimestamp", timestamp);
var query = fields.ConstructQueryString();
var queryData = Encoding.ASCII.GetBytes(query);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = queryData.Length;
webRequest.CookieContainer = new CookieContainer();
// Write the request
using (Stream stream = webRequest.GetRequestStream())
{
stream.Write(queryData, 0, queryData.Length);
}
// Perform the request
var response = webRequest.GetResponse() as HttpWebResponse;
String res;
using (Stream stream = response.GetResponseStream())
{
res = stream.ReadAll();
}
response.Close();
var reader = new JsonReader();
var results = reader.Read<Dictionary<string, object>>(res);
return response.Cookies["steamLogin"].Value;
}
示例2: SetRequestCommonFields
void SetRequestCommonFields(
HttpWebRequest request, Action<NameValueCollection> headersCallback)
{
var fields = new NameValueCollection();
fields.Add("sessionid", LoginData.SessionId);
fields.Add("logpos", NextLogPos.ToString());
fields.Add("version", Version.ToString());
if (headersCallback != null)
headersCallback(fields);
var query = fields.ConstructQueryString();
var queryData = Encoding.ASCII.GetBytes(query);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = queryData.Length;
try
{
// Write the request
using (Stream stream = request.GetRequestStream())
stream.Write(queryData, 0, queryData.Length);
}
catch (Exception ex)
{
Console.WriteLine("Could not write query data to request: {0}",
ex.ToString());
}
}
示例3: GetKeyRSA
private static Dictionary<string, object> GetKeyRSA(string username)
{
// First ask the public RSA key for encryption.
var webRequest = WebRequest.Create(API_RSA_KEY) as HttpWebRequest;
webRequest.Method = "POST";
var fields = new NameValueCollection();
fields.Add("username", username);
var query = fields.ConstructQueryString();
byte[] data = Encoding.ASCII.GetBytes(query);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = data.Length;
// Write the request
using (Stream stream = webRequest.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
// Perform the request
var response = webRequest.GetResponse();
String res;
using (Stream stream = response.GetResponseStream())
{
res = stream.ReadAll();
}
response.Close();
var reader = new JsonReader();
var json = reader.Read<Dictionary<string, object>>(res);
return json;
}
示例4: LoadForeignInventory
/// <summary>
/// Sends a load theirs inventory request.
/// </summary>
public void LoadForeignInventory(SteamID backpackId, int appid, int contextid)
{
var service = string.Format(TradeURLAction, "foreigninventory");
var webRequest = CreateSteamRequest(service, LoginData);
var fields = new NameValueCollection();
fields.Add("sessionid", LoginData.SessionId);
fields.Add("steamid", backpackId.ConvertToUInt64().ToString());
fields.Add("appid", appid.ToString());
fields.Add("contextid", contextid.ToString());
var query = fields.ConstructQueryString();
var queryData = Encoding.ASCII.GetBytes(query);
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = queryData.Length;
// Write the request
using (Stream stream = webRequest.GetRequestStream())
{
stream.Write(queryData, 0, queryData.Length);
}
// Perform the request
var res = webRequest.BeginGetResponse(
new AsyncCallback(ProcessForeignInventory), webRequest);
}