Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/269.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用FormUrlEncodedContent的HTTP Put请求_C#_Http_Put - Fatal编程技术网

C# 使用FormUrlEncodedContent的HTTP Put请求

C# 使用FormUrlEncodedContent的HTTP Put请求,c#,http,put,C#,Http,Put,我对HTTP请求非常陌生,需要执行HTTP请求。我还想知道在完成HTTP请求后在哪里可以测试它。以下是Put请求的示例: HTTP方法:放置URL: 样本: 以下是我在request id和mfgPartID中使用键和值对存储dictionary的尝试: public异步void PutRequest(字符串URL, 字符串键1,字符串值1, 字符串键2,字符串值2) { 字典查询=新字典 { {key1,value1}, {key2,value2} }; HttpContent-SendD

我对HTTP请求非常陌生,需要执行HTTP请求。我还想知道在完成HTTP请求后在哪里可以测试它。以下是Put请求的示例:

HTTP方法:放置URL:

样本:

以下是我在
request id
mfgPartID
中使用键和值对存储
dictionary
的尝试:

public异步void PutRequest(字符串URL,
字符串键1,字符串值1,
字符串键2,字符串值2)
{
字典查询=新字典
{
{key1,value1},
{key2,value2}
};
HttpContent-SendData=新的FormUrlEncodedContent(查询);
AddHeaderAuthorization();
尝试
{
ResponseMessage=wait client.PutAsync(URL,SendData);
ResponseContent=ResponseMessage.Content;
TestResponseMessage=await ResponseContent.ReadAsStringAsync();
}
捕获(例外e)
{
TestResponseMessage=“更新错误”;
}

另外,请忽略
AddHeaderAuthorization
,因为我确信它工作正常。

只需将URL放入浏览器中即可。HTTPRequest提供与浏览器相同的结果,但数据以文本形式返回。i browser作为查看结果的附加功能非常简单。如果您有请求,则需要一台接受该请求的服务器。因此,您可以创建一个接受非安全连接(HTTP而非HTTPS)的HTTP侦听器,然后使用wireshark或fiddler等嗅探器捕获请求,以便验证格式和内容。