星期日, 1月 09, 2011

[Asp.Net] Https using WebClient

等入驗證之前先補上這一段就可以取得加密的憑證

即可用正常的webclient
try
{
System.Net.ServicePointManager.ServerCertificateValidationCallback =
delegate(object senderX, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)
{
return true;
};
HtmlText = wc.DownloadString(wc.BaseAddress);

}
catch
{
System.Environment.Exit(System.Environment.ExitCode);
}

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails