首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误:(405)方法在将文件上载到https时不允许

错误:(405)方法在将文件上载到https时不允许
EN

Stack Overflow用户
提问于 2017-02-15 05:44:17
回答 1查看 3.2K关注 0票数 0

编写代码,将文件上载到https文件夹,如下所示

代码语言:javascript
复制
WebClient webClient = new WebClient();
            string webAddress = null;
            try
            {
                webAddress = @"https://www.example.net/mydocs";
                webClient.UseDefaultCredentials = true;
                webClient.Credentials = CredentialCache.DefaultCredentials;

                WebRequest serverRequest = WebRequest.Create(webAddress);
                WebResponse serverResponse;
                serverResponse = serverRequest.GetResponse();
                serverResponse.Close();

                webClient.UploadFile(webAddress , "PUT", @"C:\d\1.xml");
                webClient.Dispose();
                webClient = null;
            }
            catch (Exception error)
            {
                MessageBox.Show(error.Message);
            }

返回错误的行webClient.UploadFile(webAddress , "PUT", @"C:\d\1.xml");

远程服务器返回一个错误:(405)方法不允许。

EN

回答 1

Stack Overflow用户

发布于 2017-02-15 05:51:41

看起来服务器上不支持PUT方法。确保这是支持的正确方法。您可以尝试使用POST

代码语言:javascript
复制
 webClient.UploadFile(webAddress , "POST", @"C:\d\1.xml");
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42241543

复制
相关文章

相似问题

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