public ActionResult ip() { //ip //string ip = Request.UserHostAddress; string ip = "213.114.158.229"; ViewBag.ip = ip; //location finding //datatable column contents are: //host,countryName,city,region,latitude,longitude,timezone; location lc = new location(); DataTable dt = lc.GetLocation(ip.Trim()); if (dt != null) { if (dt.Rows.Count > 0) { ViewBag.city = dt.Rows[0]["city"].ToString(); ViewBag.ip = dt.Rows[0]["host"].ToString(); ViewBag.region = dt.Rows[0]["region"].ToString(); ViewBag.country = dt.Rows[0]["countryName"].ToString(); ViewBag.latitude = dt.Rows[0]["latitude"].ToString(); ViewBag.longitude = dt.Rows[0]["longitude"].ToString(); } else { ViewBag.city = "invalid"; } } else { ViewBag.city = "invalid 2nd"; } Thread.Sleep(1000); return(View()); }