Z
Zach
I was looking for code to trap the visitor's IP address and found the
following:
Partial Class IP_Address
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim nowip As String
nowip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If nowip = "" Then
nowip = Request.ServerVariables("REMOTE_ADDR")
End If
If txtIPAddress.Text = "" Then
txtIPAddress.Text = nowip
End If
End Sub
End Class
......
Translating into C#, I ran into problems;
for a start the using isn't recognized:
I tried:
using System.Web.UI.Page;
// blabla
string nowip = Request.ServerVariables("HTTP_X_FORWARDED_FOR");
if(nowip == stringEmpty) nowip = Request.ServerVariables("REMOTE_ADDR");
string ip_address = " the visitor's IP address is: " + nowip;
This corde produces errors;
could you please help to get it right?
Zach.
following:
Partial Class IP_Address
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim nowip As String
nowip = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If nowip = "" Then
nowip = Request.ServerVariables("REMOTE_ADDR")
End If
If txtIPAddress.Text = "" Then
txtIPAddress.Text = nowip
End If
End Sub
End Class
......
Translating into C#, I ran into problems;
for a start the using isn't recognized:
I tried:
using System.Web.UI.Page;
// blabla
string nowip = Request.ServerVariables("HTTP_X_FORWARDED_FOR");
if(nowip == stringEmpty) nowip = Request.ServerVariables("REMOTE_ADDR");
string ip_address = " the visitor's IP address is: " + nowip;
This corde produces errors;
could you please help to get it right?
Zach.