Re: Server side variables (e.g. $_SERVER["REMOTE_ADDR"]) - dotNet equivalent?
am 28.12.2007 01:10:10 von mark
"Frank Moyles" wrote in message
news:ceKdne8KddpqoenaRVnyjwA@bt.com...
> 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();
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Re: Server side variables (e.g. $_SERVER["REMOTE_ADDR"]) - dotNetequivalent?
am 28.12.2007 13:53:58 von Guffa
Mark Rae [MVP] wrote:
> "Frank Moyles" wrote in message
> news:ceKdne8KddpqoenaRVnyjwA@bt.com...
>> 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.
--
Göran Andersson
_____
http://www.guffa.com
Re: Server side variables (e.g. $_SERVER["REMOTE_ADDR"]) - dotNet equivalent?
am 28.12.2007 14:03:53 von mark
"Göran Andersson" wrote in message
news:uIV97CVSIHA.4584@TK2MSFTNGP03.phx.gbl...
> 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.
--
Mark Rae
ASP.NET MVP
http://www.markrae.net