C# 通过代码登录网站

C# 通过代码登录网站,c#,login,httprequest,C#,Login,Httprequest,我必须通过代码从网站下载excel文件。但下载需要登录网站。所以我很困惑,我应该发布什么数据来登录代码 以下是chrome的请求: Request URL:https://206.82.192.135:4100/wgcgi.cgi?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status Request Method:POST Status Code:200 OK Request Headersview source Acce

我必须通过代码从网站下载excel文件。但下载需要登录网站。所以我很困惑,我应该发布什么数据来登录代码

以下是chrome的请求:

Request URL:https://206.82.192.135:4100/wgcgi.cgi?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:884
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Cookie:domain=null; username=CandA
Host:206.82.192.135:4100
Origin:https://206.82.192.135:4100
Referer:https://206.82.192.135:4100/wgcgi.cgi?action=fw_logon&style=fw_logon.xsl&fw_logon_type=status
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36
Query String Parametersview sourceview URL encoded
action:fw_logon
style:fw_logon.xsl
fw_logon_type:status


Request Payload
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_username"

[username appears here]
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_password"

[password appears here]
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_domain"

Firebox-DB
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_domain"

Firebox-DB
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="submit"

Login
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="action"

fw_logon
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="style"

fw_logon_progress.xsl
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic
Content-Disposition: form-data; name="fw_logon_type"

logon
------WebKitFormBoundaryPAzPZF4h5AQHA6Ic--
Response Headersview source
Connection:close
Content-Length:289
Content-Type:text/xml
Date:Wed, 21 Aug 2013 13:00:10 GMT
Server:None

如果要搜索简单的解决方案,请尝试使用
WebBrowser
控件。您可以遍历页面的所有项目,设置用户名和密码,然后单击登录按钮。

我了解了更多信息,发现我没有通过SSL身份验证,我遇到了以下异常: 无法为SSL/TLS安全通道建立信任关系

所以我从中得到了一段代码

System.Net.ServicePointManager.ServerCertificateValidationCallback=(senderX、certificate、chain、sslPolicyErrors)=>{return true;}


它解决了我的问题

我尝试使用WebBrowser控件,发布我的登录凭据,当我导航到URL时,它会打开一个新窗口并继续加载,之后什么也没有发生。请求负载是否有任何部分?因为它包含用户名和密码