title: how to get User IP address in asp.net?
body: <p>This is the label </p>
  
  <pre><code> &lt;asp:Label ID="lblIp" runat="server"&gt;&lt;/asp:Label&gt;
  </code></pre>
  
  <p>Here Code I used to get user IP address </p>
  
  <pre><code> string VisitorsIPAddr = string.Empty;
  
              if (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
              {
  
                  VisitorsIPAddr = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString();
                  lblIp.Text = VisitorsIPAddr;
              }
              else if (HttpContext.Current.Request.UserHostAddress.Length != 0)
              {
                  VisitorsIPAddr = HttpContext.Current.Request.UserHostAddress;
                  lblIp.Text = VisitorsIPAddr;
              }
  </code></pre>
  
  <p>but Always I got the same result. That was <strong>127.0.0.1</strong> and always it goes to <strong>else if</strong> state. </p>
  
  <p>further </p>
  
  <p><code>HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"]</code> <strong>did not give any result. It always give nothing</strong></p>