下载文件
摘要:string name = (i+1) + url.Substring(url.LastIndexOf('.')); string filePath = @"d:\Downloads\" + name; try { using (WebClient client = new WebClient())
阅读全文
HttpClient 发送请求出错时解决办法(转载)
摘要:原文地址:https://www.cnblogs.com/lxhbky/p/13829563.html 原因是:发送请求的消息http协议版本问题,应该设置.net 4.5支持的最高版本TLZ1.2,我原来已经遇到过一次这个坑了,只是上次的坑错误比较明显,这次的坑就这么一句不明不白的话。 哎,“发送
阅读全文
Newtonsoft.Json.dll读取json格式字符串值
摘要:using Newtonsoft.Json; using Newtonsoft.Json.Linq; string jsonText = "[{'a':'aaa','b':'bbb','c':'ccc'},{'a':'aaa2','b':'bbb2','c':'ccc2'}]"; string a = JObject.Parse(JArray.Parse(jso...
阅读全文
c# 下载并保存文件在程序目录
摘要:public void HttpDownloadFile(string url) { string strFileName = url.Substring(url.LastIndexOf("/")+1); // 设置参数 HttpWebRequest request = WebRequest.Create(u...
阅读全文
C# WebRequest简单调用WebService方法
摘要://get string res = GetStringByUrl("http://你的地址/WebService.asmx/方法名?参数=1"); //post string res = RequestWebService("http://你的地址/WebService.asmx/方法名","参数
阅读全文
C# WebService 概念,创建及引用调用
摘要:Web Service也叫XML Web Service WebService是一种可以接收从Internet或者Intranet上的其它系统中传递过来的请求,轻量级的独立的通讯技术。是:通过SOAP在Web上提供的软件服务,使用WSDL文件进行说明,并通过UDDI进行注册。 XML:(Extens
阅读全文
asp.net:验证控件中ValidationExpression的写法
摘要:手机号:"\d{11}"传真号:"\d{7,12}"EMAIL: ".{2,15}@.{2,15}\..{2,4}"邮箱正则表达式:/^[0-9a-zA-Z]+@(([0-9a-zA-Z]+)[.])+[a-z]{2,4}$/i (较好)验证数字:只能输入1个数字表达式 ^\d$描述 匹配一个数字匹...
阅读全文
ASP.NET几种页面数据绑定的用法及区别: <%#、 <%=、 <% 、<%@
摘要:: 是在绑定控件DataBind()方法执行时被执行,用于数据绑定如: : 在程序执行时被调用,可以显示后台变量值如:*.ASPx中: *.cs中: public string Title ="title";: 内联代码块里面可以在页面文件*.aspx或*.ascx文件里面嵌入后台代码如:是在*.a...
阅读全文
c# 获取客户端ip
摘要:针对HttpContext.Current.Request.UserHostAddress 如果客户使用的是代理,将获取不到真是的ip要想透过代理服务器取得客户端的真实IP地址,就要使用Request.ServerVariables("HTTP_X_FORWARDED_FOR")来读取。不过要注意的...
阅读全文
c#抓取网站数据
摘要:string url = "http://www.123.com/fast_view?a=1&gameId=25&areaId=0&serverId=0"; string reffer = "http://www.123.com/"; string htm...
阅读全文
c# 去除文本的html标签
摘要:1 public static string ContentReplace(string input) 2 { 3 input = Regex.Replace(input, @"]*)>", "", RegexOptions.IgnoreCase); 4 ...
阅读全文
C#,js数据排序及其操作
摘要:List listint=new List{2,1,7,3,8,5,4,6};listint.Sort((x, y) => x - y);var array = newArray()array.sort(function(x, y) {return Number(x[1]) - Number(y[1...
阅读全文