我已创建了一块code的,使用Web客户端从一个给定的URL下载文件。
I have create a piece of code that download a file from a given URL using WebClient.
问题是我收到的时候code试图下载从 HTTPS 网站文件下面的错误。
The problem is i am getting the following error when the code is trying to download a file from a HTTPS site.
The remote certificate is invalid according to the validation procedure这个问题只发生在服务器不在本地机器上,所以我也不知道该怎么调试。
This issue happened only on the server not on the local machine, so i also don't know how to debug it.
我看了网络上的几个答案,但没有发现任何可以帮助我。
I have read several answers on the web but didn't find anything that could help me.
这件作品code的:
using (WebClient Client = new WebClient()) { string fileName = System.Configuration.ConfigurationManager.AppSettings["siteUploadedDirectory"] + "/temp/" + Context.Timestamp.Ticks.ToString() + "_" + FileURL.Substring(FileURL.LastIndexOf('/')+1); fileName = Server.MapPath(fileName); Client.DownloadFile(FileURL, fileName); return fileName + "|" + FileURL.Substring(FileURL.LastIndexOf('/')+1); }我努力的网址:
Otakim.co.il/printreferrer.aspx?ReferrerBaseURL=cloudents &ReferrerUserName=ram &ReferrerUserToken=1 &FileURL=www.cloudents/d/lzodJqaBYHu/pD0nrbAtHSq文件网址:FileURL = www.cloudents/d/lzodJqaBYHu/pD0nrbAtHSq
任何帮助将AP preciated
Any help will be appreciated
推荐答案您可以通过以下code snieppet绕过证书验证过程
You can bypass the certificate validation process by following code snieppet
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;更多推荐
错误与下载使用WebClient的HTTPS文件
发布评论