C #, get the user to log IP addresses

the using the System.Net; // import the namespace 

public  String getLocalIP () 
{ 
String strHostName Dns.GetHostName = (); // get the host name of the machine 
the IPHostEntry ipEntry = Dns.GetHostByName (strHostName); // obtain the machine the IP 
String = ipEntry.AddressList strAddr [ 0 ] .ToString ();
 return (strAddr); 
} 

// use 
IF (rs.HasRows) 
{ 
rs.Read (); 
the Context.Session [ " DLUserID " ] RS = [ " U_UserID " ] .ToString (); 
the Context.Session [ "DLgetdate"] = rs["getdate"].ToString();

context.Session["DLUserDate"] = rs["U_Date"].ToString();
context.Session["DLUserIP"] = getLocalIP();
context.Response.Redirect("index_Main.aspx?Dl=" + rs["U_UserID"].ToString() + "&pas=" + rs["U_Pass"].ToString() + "");
rs.Close();
}
else
{ 
Context.Response.Redirect ( " Login.aspx " ); 
} 

// Get Log IP 

public  String getLocalIP () 
{ 
String strHostName Dns.GetHostName = (); // get the host name of the machine 
IPHostEntry ipEntry = Dns.GetHostByName ( strHostName); // obtain the machine the IP 
String strAddr ipEntry.AddressList = [ 0 ] .ToString ();
 return (strAddr); 
} 

public  BOOL the IsReusable 
{ 
GET 
{ 
return  to false ; 
} 
} 
} 


description: HTTP: //www.cnblogs.com/liujieblogs/p/6901279.html

 

Guess you like

Origin www.cnblogs.com/Tianxf815/p/10949252.html