Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T.

For those of you wanting to know just what is being sent (posted) back from the client (browser) to the server (ASP.NET) - when a postback occurs - use the following lines in your C# ASP.NET program:

 

string msg = "";
for (int
i = 0; i < Request.Form.AllKeys.Length; i++)
{
  msg += i.ToString() +
" " + Request.Form.GetKey(i) + ": " + Request.Form[Request.Form.GetKey(i)] + "\r\n"
;
}
System.Diagnostics.
Debug.WriteLine(msg);

Either look at the output window or put a break-point on the last line so you can use the debugger to view the variables values at runtime.

Note that this only the information within the HTTP POST payload.  There are also things like the HTTP headers, cookies etc (all of which you can query in a similar fashion - all within the Page.Request object).

Normally I'd use a tool like Fiddler for this type of interogation - but sometimes it's just as quick and easy to do it in the code like this.

HTH

Tim

Posted on Thursday, July 24, 2008 1:43 PM C# .NET , ASP.NET | Back to top


Comments on this post: How to find out what the client (browser) is posting back to the server (with ASP.NET C#)

# re: How to find out what the client (browser) is posting back to the server (with ASP.NET C#)
Requesting Gravatar...
Tested, it works.
Left by website value on Dec 08, 2011 12:47 PM

Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net