
Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
>> What is the equivalent for retrieving server side variables?
>>
>> For example in PHP, one such predefined variable is:
>> $_SERVER['REMOTE_ADDR']
>
> string strRemoteAddr = Request.ServerVariables["REMOTE_ADDR"].ToString();
The ServerVariables collection is a collection of strings, so just do:
string strRemoteAddr = Request.ServerVariables["REMOTE_ADDR"];
Besides, the collection returns null if there is no item by the
specified name, and calling ToString on a null reference causes an
exception.

Signature
Göran Andersson
_____
http://www.guffa.com
Mark Rae [MVP] - 28 Dec 2007 13:03 GMT
> The ServerVariables collection is a collection of strings, so just do:
>
> string strRemoteAddr = Request.ServerVariables["REMOTE_ADDR"];
>
> Besides, the collection returns null if there is no item by the specified
> name, and calling ToString on a null reference causes an exception.
You're quite correct - I should have been more specific.

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net