protected void Page_Load(object sender, EventArgs e)
{
string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
WriteIpToTxt(ip);
}
public void WriteIpToTxt(string ip)
{
string strfile;
strfile = "asp.txt";
string strout;
strout = "";
StreamReader sr = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(strfile), System.Text.Encoding.Default);
String input = sr.ReadToEnd();
sr.Close();
StreamWriter sw = new StreamWriter(Server.MapPath(strfile), false, System.Text.Encoding.Default);
sw.Write(input+"IP:");
sw.Write(ip+"\r\n");
sw.Close();
strout = input;
}
{
string ip = System.Web.HttpContext.Current.Request.UserHostAddress;
WriteIpToTxt(ip);
}
public void WriteIpToTxt(string ip)
{
string strfile;
strfile = "asp.txt";
string strout;
strout = "";
StreamReader sr = new StreamReader(System.Web.HttpContext.Current.Server.MapPath(strfile), System.Text.Encoding.Default);
String input = sr.ReadToEnd();
sr.Close();
StreamWriter sw = new StreamWriter(Server.MapPath(strfile), false, System.Text.Encoding.Default);
sw.Write(input+"IP:");
sw.Write(ip+"\r\n");
sw.Close();
strout = input;
}