【发布时间】:2012-04-09 14:54:37
【问题描述】:
我正在尝试使用 .NET Micro Framework (C#) 从 Fez Panda II 微控制器板上进行 HTTP POST,但是当我尝试获取请求流。我似乎在互联网上的任何地方都找不到有关此特定错误的任何信息。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.urlofthewebsite.com/Word/");
string name = "00ABCDEFDEADBEEF";
string rawData = "2012-02-08\t14:53:08\t755F66";
try
{
string postData = "deviceID=" + name + "&rawData=" + rawData;
Debug.Print(postData);
byte[] data = Encoding.UTF8.GetBytes(postData);
//request.ContentType = "application/x-www-form-urlencoded";
//request.ContentLength = data.Length;
//Set parameters of web request for HTTP POST
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
request.KeepAlive = false;
//Create a stream to send the post data to
//ERROR OCCURS HERE
Stream postDataStream = request.GetRequestStream();
etc.
调试输出:
#### Exception System.Exception - 0x00000000 (1) ####
#### Message: DNS server IP address was not found.
#### GHIElectronics.NETMF.Net.Dns::GetHostEntry [IP: 0038] ####
#### GHIElectronics.NETMF.Net.HttpWebRequest::EstablishConnection [IP: 00e1] ####
#### GHIElectronics.NETMF.Net.HttpWebRequest::SubmitRequest [IP: 0013] ####
#### GHIElectronics.NETMF.Net.HttpWebRequest::GetRequestStream [IP: 0008] ####
#### Fresh_Step.Program::httpPostRawData [IP: 0052] ####
#### Fresh_Step.Program::Main [IP: 0004] ####
A first chance exception of type 'System.Exception' occurred in GHIElectronics.NETMF.W5100.Http.dll
可能是什么问题?很感谢任何形式的帮助。如果需要其他信息,我很乐意提供。
【问题讨论】:
-
您可以给我们一个指向您要提交的页面的链接吗?
标签: c# .net http post .net-micro-framework