将 HTTP 身份验证与 C# WebRequest 结合使用
我想向需要身份验证的页面发出网络请求。 我该怎么做呢? 我发现一些内容可能会使用 Credentials 属性,但我不确定如何使用它。
I want to make a web request to a page that needs authenticating. How would I go about doing this? I found something that said possibly to use the Credentials property, but I'm not sure how to use it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将新的 NetworkCredential 实例分配给 Credentials 属性:
Assign a new
NetworkCredential
instance to theCredentials
property:基本身份验证示例:
http://blog.kowalczyk.info/article/ at3/Forcing-basic-http-authentication-for-HttpWebReq.html
Basic auth example:
http://blog.kowalczyk.info/article/at3/Forcing-basic-http-authentication-for-HttpWebReq.html
也可以自动进行身份验证。 这将使用当前登录用户的凭据。
It is also possible to authenticate automatically with. This will use the credentials of the currently logged on user.