Thursday, January 26, 2006 2:21 AM
Untitled Page
Something is not right with this code:
foreach
(string key in
Request.ServerVariables.Keys)
Response.Write(string.Format("<b>{0}</b>:
{1}<br>", key,
Request.ServerVariables[key]));
An error occurred saying:
Collection was modified after the enumerator was instantiated.
And so I tried:
for
(int i = 0; i < Request.ServerVariables.Keys.Count;
i++)
{
string
key = Request.ServerVariables.Keys[i];
Response.Write(string.Format("<b>{0}</b>:
{1}<br>", key,
Request.ServerVariables[key]));
}
Again, I tried a couple of things with the first code snippet:
IEnumerator en = Request.ServerVariables.Keys.GetEnumerator();
en.MoveNext();
foreach
(string key in
Request.ServerVariables.Keys)
Response.Write(string.Format("<b>{0}</b>:
{1}<br>", key,
Request.ServerVariables[key]));
Whoooaaaa! it worked! And that’s .Net
2005 for you baby!