如何从 VB.NET 读取受 .htaccess 保护的 Web 文件
我需要访问位于 Web 服务器上安全位置的 XML 文件。文件的安全性是使用 htaccess 来完成的。 如何从 VB.NET(或任何 .NET)读取此文件并提供必要的凭据?
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, providing the necessary credentials ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您的意思是您需要提供用户名和密码。
为此,请在
HttpWebRequest
上设置一个Credentials
对象。有关详细信息和示例,请参阅文档:http:// /msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx
I assume you mean that you need to supply a username and password.
To do this, set a
Credentials
object on theHttpWebRequest
. See the documentation for more information and an example:http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx
如果您使用的是 WebClient< /a> 要检索文件,请为其提供 NetworkCredential 对象,如下所示:
If you are using a WebClient to retrieve the file, supply it with a NetworkCredential object like so: