我刚刚从 ubuntu 软件中心安装了 monodevelop 并创建了一个解决方案。我正在尝试做 WebRequest.create(url)。但它一直抛出“身份验证或解密失败”。我究竟做错了什么?如果我没有做错任何事情,我应该怎么做才能完成上述工作!
我已经搜索过这个,但我无法想出一个可以解决我的问题的解决方案!
这就是我所做的......
public static string AccessURL(string url, string postcontent)
{
WebRequest request = WebRequest.Create(url);
request.Method = "POST";
byte[] byteArray = Encoding.UTF8.GetBytes(postcontent);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);
dataStream.Close();
WebResponse response = request.GetResponse();
dataStream = response.GetResponseStream();
StreamReader reader = new StreamReader(dataStream);
string responseFromServer = reader.ReadToEnd();
reader.Close();
dataStream.Close();
response.Close();
return responseFromServer;
}
提前致谢!