首页 > 代码库 > ASP.NET Post方式提交
ASP.NET Post方式提交
public static string SendMsg(string fxPhone, string fxPassword, string toPhone, string msg) { try { string url = "u=" + fxPhone + "&"; url = url + "p="; url = url + fxPassword + "&"; url = url + "to="; url = url + toPhone + "&"; url = url + "m=" + msg; string formUrl = "http://quanapi.sinaapp.com/fetion.php"; string formData = http://www.mamicode.com/url; //提交的参数"POST"; request.KeepAlive = false; request.AllowAutoRedirect = true; request.ContentType = "application/x-www-form-urlencoded"; request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"; request.ContentLength = postData.Length; // 提交请求数据 System.IO.Stream outputStream = request.GetRequestStream(); outputStream.Write(postData, 0, postData.Length); outputStream.Close(); HttpWebResponse response; Stream responseStream; StreamReader reader; string srcString; response = request.GetResponse() as HttpWebResponse; responseStream = response.GetResponseStream(); reader = new System.IO.StreamReader(responseStream, Encoding.GetEncoding("UTF-8")); srcString = reader.ReadToEnd(); string result = srcString; //返回值赋值 reader.Close(); return result; } catch { return "error"; } }
ASP.NET Post方式提交
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。