If you are troubleshooting code then you might want to consider Visual Studio.
It is available free with WebMatrix and you can start it from the top toolbar.
Once you have a breakpoint established, you can step through the code and determine the values of your variables and how they change as the code progresses.
Thanks for pointing me to Visual Studio. When I used breakpoints to debug and I was watching the value of myItem, it changes from "ALL_HTTP" to all the other server variables, but I can't see the actual "Value" of the variable. Where do i see the value of
variable in Visual studio debugging?
The easiest method may be to use a temporary variable to store the value in while you are looping through so that you can see the value during the debugging process by just checking the variable.
Visual Studio features a "Watch" window that allows you to assign variables and expression it in and it will evaluate them as code is executed.
@Mikesdotnetting
Although I have rarely had any needs to use it, I had never seen that used before. Thanks!
sanman02150
Member
1 Points
3 Posts
How to list over server variables and output value of each variable?
Jan 18, 2013 04:35 PM|LINK
I'm sorry that this is a very basic question but I haven't been able to find the right way to do this.
I have the following code that lists all the server variables, but I want to actually list the value of the server variables next to it:
<ul> @foreach (var myItem in Request.ServerVariables) { <li>@myItem : I need value here for each variable </li> } </ul>Rion William...
All-Star
27866 Points
4611 Posts
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 04:46 PM|LINK
You will need to iterate through the entire collection of ServerVariables and output the following :
You can use the following code to do exactly what you are looking for :
<ul> @foreach (var myItem in Request.ServerVariables){ <li>@String.Format("{0}:{1}", myItem.ToString(), Request.ServerVariables[myItem.ToString()])</li> } </ul>sanman02150
Member
1 Points
3 Posts
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 04:56 PM|LINK
Awesome! that works. Thanks so much.
wavemaster
Participant
1293 Points
1129 Posts
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 06:02 PM|LINK
If you are troubleshooting code then you might want to consider Visual Studio.
It is available free with WebMatrix and you can start it from the top toolbar.
Once you have a breakpoint established, you can step through the code and determine the values of your variables and how they change as the code progresses.
sanman02150
Member
1 Points
3 Posts
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 06:50 PM|LINK
Thanks for pointing me to Visual Studio. When I used breakpoints to debug and I was watching the value of myItem, it changes from "ALL_HTTP" to all the other server variables, but I can't see the actual "Value" of the variable. Where do i see the value of variable in Visual studio debugging?
Mikesdotnett...
All-Star
154941 Points
19870 Posts
Moderator
MVP
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 07:00 PM|LINK
There is actually a helper for displaying server variables:
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
wavemaster
Participant
1293 Points
1129 Posts
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 07:13 PM|LINK
there is a plus sign in that box that pops up. Expand that and weed through too many layers of information eventually you will find the values .
Have not yet figured out myself which node I need. I just wander through there aimlessly until I find something.
Rion William...
All-Star
27866 Points
4611 Posts
Re: How to list over server variables and output value of each variable?
Jan 18, 2013 07:13 PM|LINK
@sanman
The easiest method may be to use a temporary variable to store the value in while you are looping through so that you can see the value during the debugging process by just checking the variable.
Visual Studio features a "Watch" window that allows you to assign variables and expression it in and it will evaluate them as code is executed.
@Mikesdotnetting
Although I have rarely had any needs to use it, I had never seen that used before. Thanks!