首页 > 编程 > .NET > 正文

ASP.NET POST方式提交数据

2024-07-10 12:57:15
字体:
来源:转载
供稿:网友
string url = "网址";
httpwebrequest req = (httpwebrequest)webrequest.create(url);
string s = "要提交的数据";
byte[] requestbytes = system.text.encoding.ascii.getbytes (logininfo);
req.method = "post";
req.contenttype = "application/x-www-form-urlencoded";
req.contentlength = requestbytes.length;
stream requeststream = req.getrequeststream();
requeststream.write(requestbytes,0,requestbytes.length);
requeststream.close();

httpwebresponse res = (httpwebresponse)req.getresponse();
streamreader sr = new streamreader(res.getresponsestream(), system.text.encoding.default);
string backstr = sr.readtoend();
response.write(line);
sr.close();
res.close();


最大的网站源码资源下载站,

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表