How To get IP Address to Country/State using www.hostip.info

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Net;
using System.Text;

public partial class IpInfo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string ipUrl = "http://www.hostip.info/api/get.html?ip=" + Request.UserHostAddress;
       
       
        WebClient webClient = new WebClient();
        Byte[] ipInfoBytes = webClient.DownloadData(ipUrl);
        UTF8Encoding encoding = new UTF8Encoding();
        string ipInfo = encoding.GetString(ipInfoBytes);

        Response.Write(ipInfo);

    }
}

Please do not post any spam link in the comment box😊

إرسال تعليق (0)
أحدث أقدم