I need to access a XML file located in a secured location on a web server. The security of the file is done using htaccess. How can I read from VB.NET (or any .NET) this file, providin开发者_运维百科g the necessary credentials ?
I assume you mean that you need to supply a username and password.
To do this, set a Credentials
object on the HttpWebRequest
. See the documentation for more information and an example:
http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx
If you are using a WebClient to retrieve the file, supply it with a NetworkCredential object like so:
Dim wc As New WebClient() With {
.Credentials = New NetworkCredentials("MyUserName", "MyPassword")
}
精彩评论