Which one is the Best way?? (client IP address)
-
Hi, I am able to get the client IP address using the following 3 ways string test = Request.UserHostAddress.ToString(); string test2 = Request.ServerVariables["REMOTE_ADDR"].ToString(); string test3 = Context.Request.UserHostAddress.ToString(); All are returning the same values... But which one is the Best (accuracy and performance wise) and More reliable in all respects. Which one should I use?? Regards, ~JJ
-
Hi, I am able to get the client IP address using the following 3 ways string test = Request.UserHostAddress.ToString(); string test2 = Request.ServerVariables["REMOTE_ADDR"].ToString(); string test3 = Context.Request.UserHostAddress.ToString(); All are returning the same values... But which one is the Best (accuracy and performance wise) and More reliable in all respects. Which one should I use?? Regards, ~JJ
-
Mogaambo kush hua :)
-
Mogaambo kush hua :)
-
Hi, I am able to get the client IP address using the following 3 ways string test = Request.UserHostAddress.ToString(); string test2 = Request.ServerVariables["REMOTE_ADDR"].ToString(); string test3 = Context.Request.UserHostAddress.ToString(); All are returning the same values... But which one is the Best (accuracy and performance wise) and More reliable in all respects. Which one should I use?? Regards, ~JJ
They are all the same. However, they are already strings, so there is no reason to use ToString:
string test = Request.UserHostAddress;
string test2 = Request.ServerVariables["REMOTE_ADDR"];
string test3 = Context.Request.UserHostAddress;Also:
string test4 = Context.Request.ServerVariables["REMOTE_ADDR"];
string test5 = Page.Request.UserHostAddress;
string test6 = Page.Request.ServerVariables["REMOTE_ADDR"];
string test7 = Page.Page.Request.UserHostAddress;
string test8 = Page.Page.Request.ServerVariables["REMOTE_ADDR"];
string test9 = HttpContext.Current.Request.UserHostAddress;
string test10 = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
string test11 = ((Page)(HttpContext.Current.Handler)).Request.UserHostAddress;
string test12 = ((Page)(HttpContext.Current.Handler)).Request.ServerVariables["REMOTE_ADDR"];
string test13 = ((Page)(HttpContext.Current.Handler)).Page.Request.UserHostAddress;
string test14 = ((Page)(HttpContext.Current.Handler)).Page.Request.ServerVariables["REMOTE_ADDR"];Despite everything, the person most likely to be fooling you next is yourself.