How to capture user details like user identity or ip. Currently I am working with c# mvc, my current project is working fine and can capture the user name and ip only in running on debbug mode on my local project but if I am going to publish it to server IIS every client will just get the server info rather than their identity.
Here is my simple current flow:
On my View I have this to display the user name:
<html>
<body>
<a id="test" class="navbar-brand" href="#" style="float:right">User</a>
<html>
</body>
<script>
$(document).ready(function () {
$.ajax({
url: '/Home/getUserInfo',
type: 'GET',
dataType: 'json',
success: function (data) {
document.getElementById("test").innerHTML = data;
},
error: function (jqXhr, textStatus, errorThrown) {
alert(errorThrown);
}
});
});
</script>
And on my controller I have this function:
public ActionResult getUserInfo()
{
System.Security.Principal.WindowsIdentity user = System.Security.Principal.WindowsIdentity.GetCurrent();
string name = user.Name;
return Json(name, JsonRequestBehavior.AllowGet);
}
Any suggestion/Comments TIA.