首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >远程服务器返回错误:"(405)方法不允许“

远程服务器返回错误:"(405)方法不允许“
EN

Stack Overflow用户
提问于 2014-04-22 16:08:31
回答 4查看 17.6K关注 0票数 5

在阅读了同一主题的不同答案后,我几乎尝试了他们讨论中提到的所有选项,但我仍然收到错误:

Error No1The remote server returned an error: (404) Not Found. OR

Error No2The remote server returned an error: (405) Method Not Allowed__。

下面是我的代码:

代码语言:javascript
复制
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();

我在最后一行收到错误,即

代码语言:javascript
复制
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

如果我使用httpWebRequest.Method="GET",我会收到如上所述的错误号1,如果我使用httpWebRequest.Method="Post",我会收到错误号2。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23213967

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档