在htp服务器上建立文件夹,使用HttpWebRequest在服务器上创建目录

I am trying to create directory on server via https. But while returning the response it generates exceptions: “The remote server returned an error: (404) Not Found.”

The code is as follows:

string szURL3 = @"https://directoryurl/TestDir/";

//Create an HTTP request for the URL.

HttpWebRequest httpMkColRequest = (HttpWebRequest)WebRequest.Create(szURL3);

// Set up new credentials.

httpMkColRequest.Credentials = new NetworkCredential(_httpsUserName, _httpsPassword);

// Pre-authenticate the request.

httpMkColRequest.PreAuthenticate = true;

// Define the HTTP method.

httpMkColRequest.Method = @"MKCOL";

// Retrieve the response.

HttpWebResponse httpMkColResponse = (HttpWebResponse)httpMkColRequest.GetResponse();

//Write the response status to the console.

Console.WriteLine(@"MKCOL Response: {0}",httpMkColResponse.StatusDescription);

Could anybody support regarding this. I am able to get the directory information correctly in the same way. As I referred some links:

http://blogs.msdn.com/b/robert_mcmurray/archive/2011/10/18/sending-webdav-requests-in-net-revisited.aspx

According to this, what I understood is that the resources are locked. But how to unlock the resources for creating directory.

Please correct where modification required.

Solutions1

I solved the issue. The webDAV Configuration on the server was not enabled.

Talk1:

This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.

Talk2:

The webDAV Configuration was not correct due to that reason, different kinds of exception were generated for the different methods.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值