在阅读了同一主题的不同答案后,我几乎尝试了他们讨论中提到的所有选项,但我仍然收到错误:
Error No1:The remote server returned an error: (404) Not Found.
OR
Error No2The remote server returned an error: (405) Method Not Allowed
__。
下面是我的代码:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("URL?Paramter1=pc&user=u1&password=p1");
httpWebRequest.ContentType = "application/json; charset=utf-8";
httpWebRequest.Method = "POST";
httpWebRequest.Accept = "application/json";
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
我在最后一行收到错误,即
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
如果我使用httpWebRequest.Method="GET"
,我会收到如上所述的错误号1,如果我使用httpWebRequest.Method="Post"
,我会收到错误号2。
https://stackoverflow.com/questions/23213967
复制相似问题