DefaultNetworkCredentials 或 DefaultCredentials

发布于 2024-08-27 03:53:06 字数 60 浏览 2 评论 0原文

当我需要向代理(本地或网络中)提供凭据时,我应该使用哪一个?

这两者之间的确切区别是什么?

Which one am I supposed to use when I need to supply a credential to a proxy (local or in Network)?

What's the exact difference between these two?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

独守阴晴ぅ圆缺 2024-09-03 03:53:06

它们是完全相同的东西,您可以使用像 Reflector 这样的反汇编器亲自确认这一点。唯一的区别是 DefaultNetworkCredentials 返回一个 NetworkCredentials 对象,并且 DefaultCredentials 将其转换为 ICredentials。因此,您可以使用 NetworkCredentials 对象访问更多信息,但是您使用哪一个提供给需要 ICredentials 实例的对象没有区别,因为它是相同的对象实例:object.ReferenceEquals(CredentialCache.DefaultCredentials, CredentialCache. DefaultNetworkCredentials) 返回 true

They are exactly the same thing, which you can confirm for yourself using a disassembler like Reflector. The only difference is that DefaultNetworkCredentials returns a NetworkCredentials object and and DefaultCredentials casts it to ICredentials. So you have access to more information with a NetworkCredentials object, but which of those you use supply to an object requiring an ICredentials instance makes no difference, since it's the same object instance: object.ReferenceEquals(CredentialCache.DefaultCredentials, CredentialCache.DefaultNetworkCredentials) returns true.

家住魔仙堡 2024-09-03 03:53:06

两者之间的差异非常微妙。 DefaultNetworkCredentials 是两者中较新的一个(.NET 2.0 中添加的),其核心区别在于,在某些安全条件下,它可以向应用程序公开有关登录用户的更多隐私信息。有关详细信息,请尝试此博客文章:

http://blogs. msdn.com/buckh/archive/2004/07/28/199706.aspx

The difference between the two is very subtle. DefaultNetworkCredentials is the newer of the two (added with .NET 2.0), and the core difference is that under certain security conditions, it can expose more private information about the logged-in user to the application. For more information, try this blog post:

http://blogs.msdn.com/buckh/archive/2004/07/28/199706.aspx

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