Tim Huffam

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

  Home  |   Contact  |   Syndication    |   Login
  153 Posts | 0 Stories | 2415 Comments | 653 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

Feedback

# re: How to find out what the client (browser) is posting back to the server (with ASP.NET C#) 12/8/2011 12:47 PM website value
Tested, it works.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: