I am storing sessions for all those admins who login and logout from my website , also i want to store their ip address , i am using asp.net mvc and c# is language . . . how do i capture their ip adress?
Asked
Active
Viewed 189 times
2 Answers
0
Could you try using Request.UserHostAddress
. This would return the ip-address for the current user.

scheien
- 2,457
- 1
- 19
- 22
-1
I would use JavaScript to populate a hidden field on the login form with their IP address.
<script type="application/javascript">
function getip(json){
document.getElementById("hiddenIpField").value=json.ip;
}
</script>
<script type="application/javascript" src="http://jsonip.appspot.com/?callback=getip"></script>

Chad
- 164
- 10
-
Note that a javascript solution is particularly easy to manipulate. A hidden field can simply be changed before the POST occurs. – Rowan Freeman May 15 '14 at 06:27
-
True @Rowan, but you can always have the code run in an onsubmit event handler. – Chad May 15 '14 at 06:35