/// <summary>
/// Returns the content of the POST buffer as string
/// </summary>
/// <returns></returns>
public static string FormBufferToString()
{
HttpRequest Request = HttpContext.Current.Request;
if (Request.TotalBytes > 0)
return Encoding.Default.GetString(Request.BinaryRead(Request.TotalBytes));
return string.Empty;
}
disano357
Member
2 Points
3 Posts
data from http post method to string
Aug 31, 2011 08:40 PM|LINK
Hi everybody,
I have a little problem. I need to receive a post message from a site and turn it into a string, for this I have setup a generic handler. And try using the code found on this page http://msdn.microsoft.com/en-us/library/system.web.httprequest.inputstream.aspx
But it doesn't seem to work. I know a request is being sent, but I just can't seem to catch it, any advice?
rstrahl
Contributor
2287 Points
387 Posts
ASPInsiders
MVP
Re: data from http post method to string
Aug 31, 2011 10:58 PM|LINK
You should be able to use something like this:
/// <summary> /// Returns the content of the POST buffer as string /// </summary> /// <returns></returns> public static string FormBufferToString() { HttpRequest Request = HttpContext.Current.Request; if (Request.TotalBytes > 0) return Encoding.Default.GetString(Request.BinaryRead(Request.TotalBytes)); return string.Empty; }There's more info on this topic here:
http://www.west-wind.com/weblog/posts/2011/Jan/17/Retrieve-the-full-ASPNET-Form-Buffer-as-a-String
Hope this helps,
+++ Rick ---
West Wind Technologies
Making waves on the Web
www.west-wind.com/weblog