473,738 Members | 10,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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
3 4551
"Frank Moyles" <fg******@nospa m.comwrote in message
news:ce******** *************@b t.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.ServerV ariables["REMOTE_ADD R"].ToString();
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Dec 28 '07 #2
Mark Rae [MVP] wrote:
"Frank Moyles" <fg******@nospa m.comwrote in message
news:ce******** *************@b t.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.ServerV ariables["REMOTE_ADD R"].ToString();
The ServerVariables collection is a collection of strings, so just do:

string strRemoteAddr = Request.ServerV ariables["REMOTE_ADD R"];

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
"Göran Andersson" <gu***@guffa.co mwrote in message
news:uI******** ******@TK2MSFTN GP03.phx.gbl...
The ServerVariables collection is a collection of strings, so just do:

string strRemoteAddr = Request.ServerV ariables["REMOTE_ADD R"];

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
2351
by: David C. Holley | last post by:
How would I run a JavaScript function in a *.asp page and then pass the value returned to VBScript for further processing? ***Converting the function to VBScript is *NOT* an option.
12
12431
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank, 'height=200,width=400,status=no,toolbar=no, menubar=no,location=no resizable=no scrollable=no'); but I can't seem to invoke the client side script from within a Server Side Form. I know I can use the context with to Response.redirect or Server.transfer to return a
4
3258
by: Bratislav Jevtic | last post by:
hi, ASP.NET, framework 1.0, patch 2, Windows 2000 server is this possible: from server side to say "go back" to browser? ------------------- scenario: I've got some page with a list. When one clicks some button goes to "detail" page - for to add/update data. That form may have number of postbacks. On
1
2841
by: oreng | last post by:
Hey all, I have some problems detecting whether the client's browser javascript is enabled at the server side. While Request.Browser.JavaScript only check if the browser enable java script (and so on with Request.Browser.Cookies). I saw some server controls that register a startup script on the page_load and then perform a postback and run the javascript,changing a hidden
4
1073
by: | last post by:
I use user session to store user-specific data, but how can I store server-side data for the entire web-application? My current solution is to define static fields - or something like that - in a class. Does have ASP.NET a mechanism to store such data? Thanks, Jamal
4
5329
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label that can be ignored). When I press the button the first time, the click handler hides the textbox. Pressing the button a second time unhides the textbox. The text box is maintaining its value when hidden via view state. (The value is NOT being...
2
1394
by: xeo | last post by:
hey. Am not that advanced in php.. but some how i wanna know how 2 make server side variables, example: lets say i wanna put a clock on the server every 30 mins an action occurs
18
5446
by: Thomas Lunsford | last post by:
I have inherited a set of asp pages that I now need to augment. In order to minimize changes to production code, I would like to make a "call" to an asp page from a new asp page. Existing code is using many Request.Form variables, and I would very much prefer not to change this code. The new page will retrieve data that I would like to fill into Request.Form variables that are used in the old code. So, is it possible for me to set...
5
2263
by: =?Utf-8?B?dXNmaW5lY2F0cw==?= | last post by:
I'm new to asp.net. I'm trying to follow the tutorial walkthroughs and have got a few done. Now I'm doing the one about validating input, and I've run into some problems. In particular, I am watching very intermittent behavior of my ASP page. when I execute: protected void buttonSubmit_Click(object sender, EventArgs e) {
0
8788
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9263
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8210
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6751
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6053
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.