C#SSL基本接入认证 [英] C# SSL Basic Access Authentication
问题描述
我想从第三方索取报告,他们需要基本访问认证通过POST:
客户端应用程序必须使用基本接入认证
发送的用户名和密码。
块引用>有人能指出我在正确的方向或建议如何与C#做到这一点的教程?
编辑:我确实看到<一个href=\"http://stackoverflow.com/questions/450380/login-to-the-page-with-httpwebrequest/595318#595318\">this帖子但有两个答案,我不知道如果多数民众赞成什么,我需要做什么或哪一个是preferred方法。
解决方案假设你使用的WebRequest,您可以将CredentialCache您的要求:
的NetworkCredential NC =新的NetworkCredential(用户,密码);
CredentialCache CC =新CredentialCache();
cc.Add(www.site.com,443,基本,NC);
WebRequest的请求= WebRequest.Create(https://www.site.com);
request.Credentials = CC;
要求preAuthenticate = TRUE。
request.Method =POST; //其他请求属性填写在这里,如内容 WebResponse类respose = request.GetResponse();I want to request reports from a third party and they require "Basic Access Authentication" via POST:
Your client application must use Basic Access Authentication to send the user name and password.
Can someone point me in the right direction or recommend a tutorial on how to do this with C#?
Edit: I did see this post but there are two answers and I'm not sure if thats what I need to do or which one is the preferred method.
解决方案Assuming you use a WebRequest, you attach a CredentialCache to your request:
NetworkCredential nc = new NetworkCredential("user", "password"); CredentialCache cc = new CredentialCache(); cc.Add("www.site.com", 443, "Basic", nc); WebRequest request = WebRequest.Create("https://www.site.com"); request.Credentials = cc; request.PreAuthenticate = true; request.Method = "POST"; // fill in other request properties here, like content WebResponse respose = request.GetResponse();
这篇关于C#SSL基本接入认证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!