如何从 VB.NET 读取受 .htaccess 保护的 Web 文件

发布于 2024-12-04 08:17:35 字数 95 浏览 0 评论 0原文

我需要访问位于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

来日方长 2024-12-11 08:17:35

我假设您的意思是您需要提供用户名和密码。

为此,请在 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 the HttpWebRequest. See the documentation for more information and an example:

http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.credentials.aspx

允世 2024-12-11 08:17:35

如果您使用的是 WebClient< /a> 要检索文件,请为其提供 NetworkCredential 对象,如下所示:

Dim wc As New WebClient() With {
    .Credentials = New NetworkCredentials("MyUserName", "MyPassword")
}

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")
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文