How to get client IPhttp://forums.asp.net/t/1771039.aspx/1?How+to+get+client+IPSun, 19 Feb 2012 13:49:19 -050017710394838858http://forums.asp.net/p/1771039/4838858.aspx/1?How+to+get+client+IPHow to get client IP <p><span id="result_box" lang="en" class="long_text short_text"><span>How to obtain</span> <span class="hps">the</span> <span class="hps">real IP</span> <span class="hps">of</span> <span class="hps">the</span> <span class="hps">client??</span></span></p> 2012-02-18T14:45:05-05:004838874http://forums.asp.net/p/1771039/4838874.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p>Hi!</p> <p>here is the code:</p> <pre class="prettyprint"><strong> file name : how-to-Get-client-IP-address.aspx</strong> &lt;%@ Page Language=&quot;VB&quot; AutoEventWireup=&quot;false&quot; CodeFile=&quot;how-to-Get-client-IP-address.aspx.vb&quot;Inherits=&quot;how_to_Get_client_IP_address&quot; %&gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt; &lt;head&gt; &lt;title&gt;How to Get the client IP address&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&quot;form1&quot; runat=&quot;server&quot;&gt; &lt;div&gt; Your IP Address : &lt;asp:Label ID=&quot;Label1&quot; runat=&quot;server&quot; Text=&quot;Label&quot; Width=&quot;150px&quot; BackColor=&quot;#3399FF&quot; BorderColor=&quot;Red&quot; BorderStyle=&quot;Dotted&quot; &gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; <strong>File Name: how-to-Get-client-IP-address.aspx.vb </strong> Partial Class how_to_Get_client_IP_address Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ClientIP As String ClientIP = Request.UserHostAddress Label1.Text = ClientIP End Sub End Class</pre> <p>Thanks</p> 2012-02-18T15:21:46-05:004838897http://forums.asp.net/p/1771039/4838897.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p>Hi</p> <p><pre class="prettyprint">Request.ServerVariables[&quot;REMOTE_ADDR&quot;]</pre><span>&nbsp;should work - either directly in a view or in the controller action method body (Request is a property of Controller class in MVC, not Page).&nbsp;</span></p> <p><span><a href="http://stackoverflow.com/questions/2717702/how-do-you-get-the-users-ip-address-in-castle-mvc-monorail">http://stackoverflow.com/questions/2717702/how-do-you-get-the-users-ip-address-in-castle-mvc-monorail</a>&nbsp;</span></p> <p><span><a href="http://stackoverflow.com/questions/2577496/how-can-i-get-the-clients-ip-address-in-asp-net-mvc">http://stackoverflow.com/questions/2577496/how-can-i-get-the-clients-ip-address-in-asp-net-mvc</a></span></p> 2012-02-18T16:04:16-05:004838911http://forums.asp.net/p/1771039/4838911.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p>String hst = Dns.GetHostName();<br> IPAddress[] ip = Dns.GetHostAddresses(hst);<br> Texbox1.Text = ip[0].ToString();</p> 2012-02-18T16:19:20-05:004839149http://forums.asp.net/p/1771039/4839149.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p>note. unless it your local lan, this will not be the true ipaddres of the client, but the nat address given by the isp. also if you webserver is behind a firewall, then it will be the firewalls ipaddress. in this case the firewall should have added a hostheader with the ipaddress. see your firewall docs.</p> <p></p> 2012-02-19T00:18:07-05:004839704http://forums.asp.net/p/1771039/4839704.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p><span id="result_box" lang="en" class="long_text short_text"><span>Request.UserHostAddress</span> <span class="hps">in</span> <span class="hps">mvc4</span> <span class="hps">does not</span> <span class="hps">pass.</span></span></p> 2012-02-19T13:39:50-05:004839706http://forums.asp.net/p/1771039/4839706.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p><span id="result_box" lang="en" class="long_text short_text"><span>I</span> <span class="hps"> made</span> <span class="hps">the value of</span> <span class="hps">IP</span> <span class="hps"> :::</span> <span class="hps">1</span></span></p> 2012-02-19T13:41:32-05:004839714http://forums.asp.net/p/1771039/4839714.aspx/1?Re+How+to+get+client+IPRe: How to get client IP <p><span id="result_box" lang="en" class="long_text short_text"><span>Is it because of</span> <span class="hps">the</span> <span class="hps">work</span> <span class="hps">under</span> <span class="hps">mvc4</span><span>?</span></span></p> 2012-02-19T13:49:19-05:00