C# 获取页面Post过来的数据

/// <summary>
/// 获取post过来的数据
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
private static string PostInput(System.Web.UI.Page page)
{
try
{

System.IO.Stream s = page.Request.InputStream;

int count = 0;

byte[] buffer = new byte[1024];

StringBuilder builder = new StringBuilder();

while ((count = s.Read(buffer, 0, 1024)) > 0)
{

builder.Append(Encoding.UTF8.GetString(buffer, 0, count));

}

s.Flush();

s.Close();

s.Dispose();

return builder.ToString();

}
catch (Exception ex)
{
throw ex;
}
}

posted @ 2014-12-19 17:04  @睦  阅读(2228)  评论(0编辑  收藏  举报