Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6226531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:02:59+00:00 2026-05-24T09:02:59+00:00

I have the following code: string ip = Request.ServerVariables[REMOTE_ADDR]; Which, in the test environment

  • 0

I have the following code:

string ip = Request.ServerVariables["REMOTE_ADDR"];

Which, in the test environment does return the user IP addrress, but when we deploy the website to production, this variable has the IP of the server where the application is hosted. Any help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:03:00+00:00Added an answer on May 24, 2026 at 9:03 am

    My guess is that there is a proxy in the middle. Use HTTP_X_FORWARDED_FOR first, and if that’s null, then use REMOTE_ADDR

    From the MSDN article:

    Although retrieving just the REMOTE_ADDR server variable should be enough, I found resources online that suggested that code like this should also check the HTTP_X_FORWARDED_FOR variable; if the request comes through a proxy server that translates the address, it’s this variable that contains the correct address. If you request a server variable that doesn’t exist, the ServerVariables property returns an empty string. Therefore, even though this property doesn’t appear in my tests, attempting to retrieve its value doesn’t cause trouble.

    UPDATE:

    If it’s a load balancer that you have have settings changed on, you should ask to see if they can have the origination IP passed through. I know this can be done with Microsoft’s ISA server.

    If that’s not an option, there are these other server variables that you can try and see if they produce a result:

    "HTTP_X_COMING_FROM"
    "HTTP_X_FORWARDED_FOR"
    "HTTP_X_FORWARDED"
    "HTTP_X_REAL_IP"
    "HTTP_VIA"
    "HTTP_COMING_FROM"
    "HTTP_FORWARDED_FOR"
    "HTTP_FORWARDED"
    "HTTP_FROM"
    "HTTP_PROXY_CONNECTION"
    "CLIENT_IP"
    "FORWARDED"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code string three() { return three; } void mutate(string& ref)
Hey guys I have the following code working which is sending a GET Request
I have the following code in child window which is working but what I
I have the following code: [WebMethod] [SoapHeader(_webServiceAuth)] public User GetUser(string username) { try {
I have the following code which handles files upload on the server. But how
I have the following code Case "Formula_MDX" Dim cubeid As String = Request("intCubeId") Dim
I have the following code: String inputFile = somefile.txt; FileInputStream in = new FileInputStream(inputFile);
I have the following code: string acctStatus = account.AccountStatus.ToString(); if (!SettableStatuses().Any(status => status ==
I have the following code: String serviceType; ServiceBrowser tmpBrowser; for (String playerName: players) {
I have the following code: string[] firstArray = { bla bla, bla bla, bla

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.