By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,911 Members | 1,137 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,911 IT Pros & Developers. It's quick & easy.

Server side variables (e.g. $_SERVER['REMOTE_ADDR']) - dotNet equivalent?

P: n/a
What is the equivalent for retrieving server side variables?

For example in PHP, one such predefined variable is: $_SERVER['REMOTE_ADDR']
Dec 28 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Frank Moyles" <fg******@nospam.comwrote in message
news:ce*********************@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

Dec 28 '07 #2

P: n/a
Mark Rae [MVP] wrote:
"Frank Moyles" <fg******@nospam.comwrote in message
news:ce*********************@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
Dec 28 '07 #3

P: n/a
"Göran Andersson" <gu***@guffa.comwrote in message
news:uI**************@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

Dec 28 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.