Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print all session/post/get variables in ASP.NET page

I am very new to ASP.NET, I'm quite used to PHP (which we unfortunately do not use at work) I'd like to print all the session variables. In PHP it's quite easy, I use:

echo '<pre>' . print_r($_SESSION, true) . '</pre>';

for this, but is there an as-easy ASP.NET equivalent?

like image 873
skerit Avatar asked Jan 18 '10 17:01

skerit


2 Answers

with box being a label.

foreach (string i in Session.Contents) {
  if (Session[i] != null) {
    box.Text += i + " = " + Session[i].ToString() + "\n";
  }
}
like image 117
corymathews Avatar answered Sep 20 '22 08:09

corymathews


Your easiest route is to just enable tracing. This will show you all of this information automatically. You can do this at the page, or the application level.

Here is a quick tutorial on getting started.

like image 28
AaronS Avatar answered Sep 21 '22 08:09

AaronS