meat meat

meat meat

  • NA
  • 6
  • 0

ACCESING WEBDAV (RUNNING ON APACHE SERVER) USING C#

Dec 20 2007 9:54 PM
HI !

My company bought a software for stroring and accessing document and the software allows us to access document using webdav. That webdav run in Apache server .

I tried to use C# to access the document from webdav but it keep throwing unauthorized 401 error.

I can access that webdav url in IE or in My Network Place and It works fine.

Can anybody tell me how to authenticate to webdav url?

Can anybody help me and show me how to access a webdav url folder ?

I want to get all the folder list and the files also.

This is the code that I wrote to access the webdav URL

 

string strRootURI = "http://URL/webdav";

string strUserName = "USERID";

string strPassword = "PASSWORD";

string strDomain = "DOMAIN";

string strQuery = "";

byte[] bytes = null;

 

System.Net.CredentialCache MyCredentialCache = new System.Net.CredentialCache();

MyCredentialCache.Add(new System.Uri(strRootURI),

"Basic",//"NTLM","Negotiate" //I TRIED THREE DIFFERENT AUTH TYPE DOESN'T WORK ALSO

new System.Net.NetworkCredential(strUserName, strPassword, strDomain)

);

// Create the HttpWebRequest object.

System.Net.HttpWebRequest Request = (System.Net.HttpWebRequest)HttpWebRequest.Create(strRootURI);

// Add the network credentials to the request.

Request.Credentials = MyCredentialCache;

System.Net.WebResponse Response = (HttpWebResponse)Request.GetResponse(); //==> THROW AN 401 UNAUTHORIZED ERROR

response.Close();