使用Request.GetBufferlessInputStream()正确的POST数据c# [英] using Request.GetBufferlessInputStream() correctly for POST data c#

查看:1632
本文介绍了使用Request.GetBufferlessInputStream()正确的POST数据c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个C#网页将被监听来自服务POST数据。我已经看到了,我可能需要使用Request.GetBufferlessInputStream(),它会读取页面数据。然后,我将进一步处理在我的code此数据。

I have created a c# web page which will be listening for POST data from a service. I've seen that I may need to use Request.GetBufferlessInputStream() which will read in the page data. I will then process this data further in my code.

不过,我不能得到这个职位的数据!我发现,我需要使用

However, I cannot get the post data! I have found that I need to use

Stream httpStream = Request.GetBufferlessInputStream();
Response.Write(httpStream.ToString());

但我不知道如何再阅读。我试图从0阅读到最后,但得到的只有数字退换(假设字节的数据?)。

but I am not sure how to then read that. I have tried reading from 0 to the end, but get only numbers returned (assume byte data?).

基本上,我希望看到一个字符串!我一直在使用卷曲假一职。这code是这里

I basically want to see a string! I've been using CURL to fake a post. That code is here

curl -H "Content Type: application/xml" -d "<callback var=\"matt\">" -X POST http://localhost:1111/Default.aspx

所以,我希望我的脚本输出&LT;回调VAR =亚光&GT; 。任何想法?

推荐答案

这是你所需要的 -

This is what you need-

Stream stream = Request.InputStream;

StreamReader reader = new StreamReader(stream, Request.ContentEncoding);

string text = reader.ReadToEnd();

这篇关于使用Request.GetBufferlessInputStream()正确的POST数据c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆