【发布时间】:2011-10-26 21:11:05
【问题描述】:
您好,我尝试用 C#(Post)编写 HTTP 请求,但我需要帮助解决错误
解释:我想将 DLC 文件的内容发送到服务器并接收解密的内容。
C#代码
public static void decryptContainer(string dlc_content)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://dcrypt.it/decrypt/paste");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.Accept = "Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
using (StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII))
{
writer.Write("content=" + dlc_content);
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
using (StreamReader reader = new StreamReader(response.GetResponseStream()))
{
Console.WriteLine(reader.ReadToEnd());
}
}
这里我收到了 html 请求
<form action="/decrypt/paste" method="post">
<fieldset>
<p class="formrow">
<label for="content">DLC content</label>
<input id="content" name="content" type="text" value="" />
</p>
<p class="buttonrow"><button type="submit">Submit »</button></p>
</fieldset>
</form>
错误信息:
{
"form_errors": {
"__all__": [
"Sorry, an error occurred while processing the container."
]
}
}
如果有人可以帮助我解决问题,将非常有帮助!
【问题讨论】:
标签: c# post httprequest