To list values of all sever environment variables in one go.
Introduction
To list all sever environment variables in one go. Most of the times we will be looking to list server variables like REMOTE_ADDR, ALL_RAW,SCRIPT_NAME,HOST_NAME.. so here is a way to list all existing sever variables in a table format.
<div style="font-family:Times New Roman;font-size:smaller;">
<table width="70%" align="center">
<tr bgcolor="#e6f1fb">
<td width="25%" align="center">
ServerVariable:
</td>
<td width="75%">
Value
</td>
</tr>
<% foreach(string Item in Request.ServerVariables){ %>
<tr>
<td width="25%">
<%= Item %>
</td>
<td width="75%">
<%=Request.ServerVariables[Item]%>
</td>
</tr>
<% } %>
</table>
</div>
Here we are looping through Request.ServerVariables collection using foreach statement and displaying the name of the ServerVariable(by <%= Item %>) and value of that variable by using Request.ServerVariables["REMOTE_ADDR"]. Screen shot of output is shown in figure below.
Conclusion
By this we can list values of all sever variables.
Enjoy...