Tim Huffam

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

  Home  |   Contact  |   Syndication    |   Login
  129 Posts | 0 Stories | 874 Comments | 677 Trackbacks

News

Archives

Post Categories

Interesting Blogs/Links

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