I have a problem when using an alias to access my Sharepoint (2013) site through code.
I want to retrieve a document from a SharePoint library.
In my browser address bar I can type either :
http://myserver.domain:port/mylibrary/mydocument.xlsx
http://myAliasTotheSiteCollection/mylibrary/mydocument.xlsx
Both are OK.
But if I want to access the same file through code, the link with the alias does not work.
Here is the code:
strLink= "http://myserver.domain:port/mylibrary/mydocument.xlsx";
System.Net.WebClient wcVar = new System.Net.WebClient();
wcVar.Credentials = new System.Net.NetworkCredential(myLogin, myPwd, myEnvironnement);
wcVar.DownloadFile(strLink, strDestination);
=> OK
strLink= "http://myAliasTotheSiteCollection/mylibrary/mydocument.xlsx";
System.Net.WebClient wcVar = new System.Net.WebClient();
wcVar.Credentials = new System.Net.NetworkCredential(myLogin, myPwd, myEnvironnement);
wcVar.DownloadFile(strLink, strDestination);
=> ERROR 401 Non Authorized
How can I do to use the alias instead of the "hard coded" address ?
Thank you

0 commentaires:
Enregistrer un commentaire