使用HTTP认证通过一个C#的WebRequest [英] Using HTTP Authentication with a C# WebRequest

查看:137
本文介绍了使用HTTP认证通过一个C#的WebRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个网络请求需要认证的页面。我将如何去这样做呢?我发现的东西,说可能要使用的凭据属性,但我不知道如何使用它。

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.

推荐答案

分配一个新的的NetworkCredential 实例给证书属性:

Assign a new NetworkCredential instance to the Credentials property:

webClient.Credentials = new NetworkCredential("Mehrdad", "Password");

这篇关于使用HTTP认证通过一个C#的WebRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆