摘要: 目的:对于用HttpWebRequest加载证书请求远端https服务器时,发生的“基础连接已经关闭:无法与远程服务器建立信任关系。”/“The underlying connection was closed. Could not establish a secure SSL/TLS connection”错误,我们可以用如下方式解决。重现:使用以下代码,你就可以得到这个错误“基础连接已经关闭:无法与远程服务器建立信任关系”:usingSystem;usingSystem.Text;usingSystem.Net;usingSystem.IO;usingSystem.Security.Cry 阅读全文
posted @ 2012-03-01 16:14 Chaoa 阅读(943) 评论(0) 推荐(0) 编辑
摘要: 首先加上引用“System.Security.DLL”,其次在工程中usingSystem.Security.Cryptography.X509Certificates;这样就可以使用"X509Certificate Class”了,它的定义参见http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemsecuritycryptographyx509certificatesx509certificateclasstopic.asp。之后我们就可以///构建请求的Http 阅读全文
posted @ 2012-03-01 16:13 Chaoa 阅读(1307) 评论(0) 推荐(0) 编辑
摘要: //中英混合字符串截断 public static string getStr(string s, int l) { string temp = s; if (Regex.Replace(temp, "[\u4e00-\u9fa5]", "zz", RegexOptions.IgnoreCase).Length <= l) { return temp; } for (int i = temp.Length; i >= 0; i--) { temp = temp.Substring(0, i); if (Regex.Replace(temp, 阅读全文
posted @ 2012-03-01 11:41 Chaoa 阅读(484) 评论(0) 推荐(0) 编辑
摘要: protected void Button1_Click(object sender, EventArgs e) { //TransmitFile实现下载/* 微软为Response对象提供了一个新的方法TransmitFile来解决使用Response.BinaryWrite 下载超过400mb的文件时导致Aspnet_wp.exe进程回收而无法成功下载的问题。 代码如下: */Response.ContentType = "application/x-zip-compressed"; Response.AddHeader("Content-Dispositio 阅读全文
posted @ 2012-03-01 11:38 Chaoa 阅读(208) 评论(0) 推荐(0) 编辑