TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sasikumar S
NA
29
36.7k
Find visitor's location using IP address
Jul 28 2011 4:06 AM
Hi friends,
I have some problem to finding visitor's location.my code could be produce some error. i have pasted my code below
Code:
string ipaddress;
System.Web.HttpRequest Request;
ipaddress =Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
ipaddress = Request.ServerVariables["REMOTE_ADDR"];
DataTable dt = GetLocation(ipaddress);
if (dt != null)
{
if (dt.Rows.Count > 0)
{
city = dt.Rows[0]["City"].ToString();
RegionName = dt.Rows[0]["RegionName"].ToString();
CountryName = dt.Rows[0]["CountryName"].ToString();
CountryCode = dt.Rows[0]["CountryCode"].ToString();
}
else
{
}
}
Error Line:
ipaddress =Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
Error message:
"Use of unassigned local variable 'Request' "
anybody knows to solve this issue and get the visitors location using ip address.
regards
sasi
Reply
Answers (
2
)
Best practice and proper class design in object oriented language
Generic List Distinct