请问一个http post返回值的问题?

chp890310 chp890310 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
winform:
 string strUrl = "http://localhost:1720/WebSite5/Default.aspx";
HttpWebRequest myReq =(HttpWebRequest)WebRequest.Create(strUrl);
myReq.Method = "post";
myReq.ContentType = "application/x-www-form-urlencoded";
myReq.ReadWriteTimeout = 1000;
HttpWebResponse myRes = (HttpWebResponse)myReq.GetResponse();
Stream streamReq = myRes.GetResponseStream();
StreamReader reader = new StreamReader(streamReq, System.Text.Encoding.UTF8);
string s = reader.ReadToEnd();
MessageBox.Show(s);

website:
protected void Page_Load(object sender, EventArgs e)
{
Stream inputStream = HttpContext.Current.Request.InputStream;
StreamReader reader = new StreamReader(inputStream, System.Text.Encoding.UTF8);
string responseContent = reader.ReadToEnd();
Response.ContentType = "text/plain";
Response.Write(responseContent);
}

我让winform向website 发出http post请求,website向winform返回一个字符串,但是我用上面代码essageBox.Show(s)显示的是整个网页?怎么做才可以返回的一个字符串?
...全文

相关推荐

评论 8
收藏 已收藏
分享
返回顶部
chp890310
C# 111,129 成员 642,539 内容