asp.net post get 数据获取方式
2010-07-02 14:48
741 查看
HttpContext.Current.Response.Clear();//清除缓冲区流中的所有内容输出。
HttpContext.Current.Response.Write(message); //将信息写入 HTTP 响应输出流。
HttpContext.Current.Response.Flush();//向客户端发送当前所有缓冲的输出。
HttpContext.Current.Response.End();将当前所有缓冲的输出发送到客户端,停止该页的执行,并引发 EndRequest 事件(停止请求)。
protected void Page_Load(object sender, EventArgs e)
{
HttpResponse hr = HttpContext.Current.Response;
hr.Clear();
hr.Write(GetGetInput());
hr.Flush();
hr.End();
}
private string GetGetInput()
{
string value = HttpContext.Current.Request.QueryString["key"];
return value;
}
private string GetPostInput()
{
try
{
System.IO.Stream s = 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));
}
return builder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
HttpContext.Current.Response.Write(message); //将信息写入 HTTP 响应输出流。
HttpContext.Current.Response.Flush();//向客户端发送当前所有缓冲的输出。
HttpContext.Current.Response.End();将当前所有缓冲的输出发送到客户端,停止该页的执行,并引发 EndRequest 事件(停止请求)。
protected void Page_Load(object sender, EventArgs e)
{
HttpResponse hr = HttpContext.Current.Response;
hr.Clear();
hr.Write(GetGetInput());
hr.Flush();
hr.End();
}
private string GetGetInput()
{
string value = HttpContext.Current.Request.QueryString["key"];
return value;
}
private string GetPostInput()
{
try
{
System.IO.Stream s = 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));
}
return builder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
相关文章推荐
- 在ASP.NET中获取Get方式和Post方式提交的数据
- 在ASP.NET中获取参数POST和GET方式提交的参数
- 在ASP.NET中获取参数POST和GET方式提交的参数
- 在ASP.NET中获取参数POST和GET方式提交的参数
- asp.net获取Post和Get数据的方法(Stream)
- asp.net 数据提交中的GET,POST, PUT,DELETE,四种方式
- asp.net JS+form表单Post和Get方式提交数据
- 在ASP.NET中获取参数POST和GET方式提交的参数 .
- ASP.NET MVC中get 和post方法传递数据的方式
- asp.net获取Post和Get数据的方法
- 总结Asp.net中Page加载PostData的具体过程 进而解决"获取动态创建的控件的PostData数据"问题
- iOS开发之iPhone通过get和post方式请求asp.net webservice
- asp.net C# 向web网站GET、POST 数据
- ASP.NET以Post方式向网页发送数据
- ASP.NET的Get和Post方式
- iOS开发之iPhone通过get和post方式请求asp.net webservice
- ASP.NET交互Rest服务接口(Jquery的Get与Post方式)
- ASP.Net Post方式获取数据流的一种简单写法
- asp.net获取传值get和post请求
- Asp.net XMLHTTP 基类 (GET,Post发送XML数据)