关于HttpWebRequest上传文件的问题 我现在上传提示错误:参数错误然后,问了对方,那人说 upload参数是必须的,我就不知道这个参数是加到哪儿的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string SendPostRequest(string url, string postString) { byte[] postData = Encoding.UTF8.GetBytes(postString); WebClient client = new WebClient(); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("ContentLength", postData.Length.ToString()); byte[] responseData = client.UploadData(url, "POST", postData); return Encoding.UTF8.GetString(responseData); }Response.Write(SendPostRequest("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity", "byProvinceName=辽宁"));看下这个 这是请求服务 参数byProvinceName是辽宁 可以正确post给server 不知道对你有没有帮助.. string SendPostRequest(string url, string postString) { byte[] postData = Encoding.UTF8.GetBytes(upload + postString); WebClient client = new WebClient(); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("ContentLength", postData.Length.ToString()); byte[] responseData = client.UploadData(url, "POST", postData); return Encoding.UTF8.GetString(responseData); }试试 string SendPostRequest(string url, string postString) { byte[] postData = Encoding.UTF8.GetBytes("upload=" + postString); WebClient client = new WebClient(); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("ContentLength", postData.Length.ToString()); byte[] responseData = client.UploadData(url, "POST", postData); return Encoding.UTF8.GetString(responseData); }试试 OK,我试试,刚才我问了对方,对方也说 upload 是上传的文件流 OK,我试试,刚才我问了对方,对方也说 upload 是上传的文件流结贴给分啊,火火火 OK,我试试,刚才我问了对方,对方也说 upload 是上传的文件流结贴给分啊,火火火上传还是不成功,一直提示参数错误 请问这样用可以吗? 有经验的来看 checkboxlist问题 如何从后台代码获得客户端数据?急!! 同样一个bookdetails.aspx页面,想根据数据库中书名的不同,动态改变此页面的TITLE属性,怎么做? DBNull转换成String时出错 有没有用owc做数据报表方面的文章啊 最近做的站,提个意见http://gdsz.haofang.asia/ datagrid问题 服务器错误 分析器错误 PageHead是用户自定义控件 三层架构没明白 伪静态正则问题
string SendPostRequest(string url, string postString)
{
byte[] postData = Encoding.UTF8.GetBytes(postString);
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Headers.Add("ContentLength", postData.Length.ToString());
byte[] responseData = client.UploadData(url, "POST", postData);
return Encoding.UTF8.GetString(responseData);
}
Response.Write(SendPostRequest("http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getSupportCity", "byProvinceName=辽宁"));
看下这个 这是请求服务 参数byProvinceName是辽宁 可以正确post给server 不知道对你有没有帮助..
{
byte[] postData = Encoding.UTF8.GetBytes(upload + postString);
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Headers.Add("ContentLength", postData.Length.ToString());
byte[] responseData = client.UploadData(url, "POST", postData);
return Encoding.UTF8.GetString(responseData);
}
试试
{
byte[] postData = Encoding.UTF8.GetBytes("upload=" + postString);
WebClient client = new WebClient();
client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
client.Headers.Add("ContentLength", postData.Length.ToString());
byte[] responseData = client.UploadData(url, "POST", postData);
return Encoding.UTF8.GetString(responseData);
}
试试